Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Channel",
description: "Create a new channel in Microsoft Teams. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-post?view=graph-rest-1.0&tabs=http)",
type: "action",
version: "0.0.9",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "List Channels",
description: "Lists all channels in a Microsoft Team. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-1.0&tabs=http)",
type: "action",
version: "0.0.9",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "List Shifts",
description: "Get the list of shift instances for a team. [See the documentation](https://learn.microsoft.com/en-us/graph/api/schedule-list-shifts?view=graph-rest-1.0&tabs=http)",
type: "action",
version: "0.0.6",
version: "0.0.7",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Send Channel Message",
description: "Send a message to a team's channel. [See the docs here](https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http)",
type: "action",
version: "0.0.9",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Send Chat Message",
description: "Send a message to a team's chat. [See the docs here](https://docs.microsoft.com/en-us/graph/api/chat-post-messages?view=graph-rest-1.0&tabs=http)",
type: "action",
version: "0.0.9",
version: "0.0.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/microsoft_teams/microsoft_teams.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default {
},
async listChatMessages({ chatId }) {
return this.makeRequest({
path: `/chats/${chatId}/messages`,
path: `/chats/${chatId}/messages?$orderby=createdDateTime%20desc`,
});
},
async listShifts({ teamId }) {
Expand Down
2 changes: 1 addition & 1 deletion components/microsoft_teams/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/microsoft_teams",
"version": "0.1.6",
"version": "0.1.7",
"description": "Pipedream Microsoft Teams Components",
"main": "microsoft_teams.app.mjs",
"keywords": [
Expand Down
36 changes: 20 additions & 16 deletions components/microsoft_teams/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,30 @@ export default {
},
},
methods: {
_getLastCreated() {
return this.db.get("lastCreated");
_getLastDate() {
return this.db.get("lastDate");
},
_setLastCreated(lastCreated) {
this.db.set("lastCreated", lastCreated);
_setLastDate(lastDate) {
this.db.set("lastDate", lastDate);
},
isNew(resource, lastCreated) {
if (!resource.createdDateTime || !lastCreated) {
getTsField() {
return "createdDateTime";
},
isNew(resource, lastDate, tsField) {
if (!tsField || !resource[tsField] || !lastDate) {
return true;
}
return Date.parse(resource.createdDateTime) > lastCreated;
return Date.parse(resource[tsField]) > lastDate;
},
async getNewPaginatedResources(fn, params, lastCreated) {
async getNewPaginatedResources(fn, params, lastDate, tsField, isSorted = false) {
const resources = [];
const paginator = this.paginate(fn, params);

for await (const resource of paginator) {
const isNewResource = this.isNew(resource, lastCreated);
const isNewResource = this.isNew(resource, lastDate, tsField);
if (isNewResource) {
resources.push(resource);
} else {
} else if (isSorted) {
break;
}
}
Expand All @@ -58,18 +61,19 @@ export default {
},
},
async run() {
let lastCreated = Date.parse(this._getLastCreated());
let lastDate = this._getLastDate();
const tsField = this.getTsField();

const resources = await this.getResources(lastCreated);
const resources = await this.getResources(lastDate, tsField);
for (const resource of resources) {
const { createdDateTime } = resource;
if (!lastCreated || (createdDateTime && Date.parse(createdDateTime) > lastCreated)) {
lastCreated = Date.parse(createdDateTime);
const date = resource[tsField];
if (!lastDate || (date && Date.parse(date) > lastDate)) {
lastDate = Date.parse(date);
}
const meta = this.generateMeta(resource);
this.$emit(resource, meta);
}

this._setLastCreated(lastCreated);
this._setLastDate(lastDate);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export default {
...base,
key: "microsoft_teams-new-channel-message",
name: "New Channel Message",
description: "Emit new event when a new message is posted in a channel",
version: "0.0.11",
description: "Emit new event when a new message is posted in a channel. [See the documentation](https://learn.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-1.0&tabs=http)",
version: "0.0.12",
type: "source",
dedupe: "unique",
props: {
Expand All @@ -28,14 +28,19 @@ export default {
},
methods: {
...base.methods,
async getResources(lastCreated) {
getTsField() {
return "lastModifiedDateTime";
},
async getResources(lastUpdated, tsField) {
return this.getNewPaginatedResources(
this.microsoftTeams.listChannelMessages,
{
teamId: this.team,
channelId: this.channel,
},
lastCreated,
lastUpdated,
tsField,
true, // Sorted by last modified date
);
},
generateMeta(message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export default {
...base,
key: "microsoft_teams-new-channel",
name: "New Channel",
description: "Emit new event when a new channel is created within a team",
version: "0.0.11",
description: "Emit new event when a new channel is created within a team. [See the documentation](https://learn.microsoft.com/en-us/graph/api/team-list-allchannels?view=graph-rest-1.0&tabs=http)",
version: "0.0.12",
type: "source",
dedupe: "unique",
props: {
Expand All @@ -19,13 +19,14 @@ export default {
},
methods: {
...base.methods,
async getResources(lastCreated) {
async getResources(lastCreated, tsField) {
return this.getNewPaginatedResources(
this.microsoftTeams.listChannels,
{
teamId: this.team,
},
lastCreated,
tsField,
);
},
generateMeta(channel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export default {
...base,
key: "microsoft_teams-new-chat-message",
name: "New Chat Message",
description: "Emit new event when a new message is received in a chat",
version: "0.0.11",
description: "Emit new event when a new message is received in a chat. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http)",
version: "0.0.12",
type: "source",
dedupe: "unique",
props: {
Expand All @@ -19,13 +19,15 @@ export default {
},
methods: {
...base.methods,
async getResources(lastCreated) {
async getResources(lastCreated, tsField) {
return this.getNewPaginatedResources(
this.microsoftTeams.listChatMessages,
{
chatId: this.chat,
},
lastCreated,
tsField,
true, // Sorted by creation date
);
},
generateMeta(message) {
Expand Down
7 changes: 4 additions & 3 deletions components/microsoft_teams/sources/new-chat/new-chat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ export default {
...base,
key: "microsoft_teams-new-chat",
name: "New Chat",
description: "Emit new event when a new chat is created",
version: "0.0.11",
description: "Emit new event when a new chat is created. [See the documentation](https://learn.microsoft.com/en-us/graph/api/chat-list?view=graph-rest-1.0&tabs=http)",
version: "0.0.12",
type: "source",
dedupe: "unique",
methods: {
...base.methods,
async getResources(lastCreated) {
async getResources(lastCreated, tsField) {
return this.getNewPaginatedResources(
this.microsoftTeams.listChats,
{},
lastCreated,
tsField,
);
},
generateMeta(chat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export default {
...base,
key: "microsoft_teams-new-team-member",
name: "New Team Member",
description: "Emit new event when a new member is added to a team",
version: "0.0.11",
description: "Emit new event when a new member is added to a team. [See the documentation](https://learn.microsoft.com/en-us/graph/api/team-list-members?view=graph-rest-1.0&tabs=http)",
version: "0.0.12",
type: "source",
dedupe: "unique",
props: {
Expand Down
7 changes: 4 additions & 3 deletions components/microsoft_teams/sources/new-team/new-team.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ export default {
...base,
key: "microsoft_teams-new-team",
name: "New Team",
description: "Emit new event when a new team is joined by the authenticated user",
version: "0.0.11",
description: "Emit new event when a new team is joined by the authenticated user. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-joinedteams?view=graph-rest-1.0&tabs=http)",
version: "0.0.12",
type: "source",
dedupe: "unique",
methods: {
...base.methods,
async getResources(lastCreated) {
async getResources(lastCreated, tsField) {
return this.getNewPaginatedResources(
this.microsoftTeams.listTeams,
{},
lastCreated,
tsField,
);
},
generateMeta(team) {
Expand Down
Loading