diff --git a/components/microsoft_teams/actions/create-channel/create-channel.mjs b/components/microsoft_teams/actions/create-channel/create-channel.mjs index 7f21aa80be3ad..65b18d4eea238 100644 --- a/components/microsoft_teams/actions/create-channel/create-channel.mjs +++ b/components/microsoft_teams/actions/create-channel/create-channel.mjs @@ -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, diff --git a/components/microsoft_teams/actions/list-channels/list-channels.mjs b/components/microsoft_teams/actions/list-channels/list-channels.mjs index baaab814b6819..93a3ee0ffdd95 100644 --- a/components/microsoft_teams/actions/list-channels/list-channels.mjs +++ b/components/microsoft_teams/actions/list-channels/list-channels.mjs @@ -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, diff --git a/components/microsoft_teams/actions/list-shifts/list-shifts.mjs b/components/microsoft_teams/actions/list-shifts/list-shifts.mjs index 5fa0429e610e9..141c50f3d2589 100644 --- a/components/microsoft_teams/actions/list-shifts/list-shifts.mjs +++ b/components/microsoft_teams/actions/list-shifts/list-shifts.mjs @@ -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, diff --git a/components/microsoft_teams/actions/send-channel-message/send-channel-message.mjs b/components/microsoft_teams/actions/send-channel-message/send-channel-message.mjs index 346f59a6ad50e..453f2ee4e0251 100644 --- a/components/microsoft_teams/actions/send-channel-message/send-channel-message.mjs +++ b/components/microsoft_teams/actions/send-channel-message/send-channel-message.mjs @@ -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, diff --git a/components/microsoft_teams/actions/send-chat-message/send-chat-message.mjs b/components/microsoft_teams/actions/send-chat-message/send-chat-message.mjs index 0d5d0276ebce9..aa3ba642b7aee 100644 --- a/components/microsoft_teams/actions/send-chat-message/send-chat-message.mjs +++ b/components/microsoft_teams/actions/send-chat-message/send-chat-message.mjs @@ -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, diff --git a/components/microsoft_teams/microsoft_teams.app.mjs b/components/microsoft_teams/microsoft_teams.app.mjs index 12edcb2f43997..6a5ea50937f43 100644 --- a/components/microsoft_teams/microsoft_teams.app.mjs +++ b/components/microsoft_teams/microsoft_teams.app.mjs @@ -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 }) { diff --git a/components/microsoft_teams/package.json b/components/microsoft_teams/package.json index 4d9c1a61e15c1..f0077d843f395 100644 --- a/components/microsoft_teams/package.json +++ b/components/microsoft_teams/package.json @@ -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": [ diff --git a/components/microsoft_teams/sources/common/base.mjs b/components/microsoft_teams/sources/common/base.mjs index 645c59ef1b67d..52f7e2ef7a132 100644 --- a/components/microsoft_teams/sources/common/base.mjs +++ b/components/microsoft_teams/sources/common/base.mjs @@ -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; } } @@ -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); }, }; diff --git a/components/microsoft_teams/sources/new-channel-message/new-channel-message.mjs b/components/microsoft_teams/sources/new-channel-message/new-channel-message.mjs index 4d20c8dde81a3..de53c82be7575 100644 --- a/components/microsoft_teams/sources/new-channel-message/new-channel-message.mjs +++ b/components/microsoft_teams/sources/new-channel-message/new-channel-message.mjs @@ -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: { @@ -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) { diff --git a/components/microsoft_teams/sources/new-channel/new-channel.mjs b/components/microsoft_teams/sources/new-channel/new-channel.mjs index 8ea131da6ac63..9054e7ce8557b 100644 --- a/components/microsoft_teams/sources/new-channel/new-channel.mjs +++ b/components/microsoft_teams/sources/new-channel/new-channel.mjs @@ -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: { @@ -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) { diff --git a/components/microsoft_teams/sources/new-chat-message/new-chat-message.mjs b/components/microsoft_teams/sources/new-chat-message/new-chat-message.mjs index 8fdb039e91f28..6abfc27b205b4 100644 --- a/components/microsoft_teams/sources/new-chat-message/new-chat-message.mjs +++ b/components/microsoft_teams/sources/new-chat-message/new-chat-message.mjs @@ -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: { @@ -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) { diff --git a/components/microsoft_teams/sources/new-chat/new-chat.mjs b/components/microsoft_teams/sources/new-chat/new-chat.mjs index af61c037aaf6d..a3473a01d6b02 100644 --- a/components/microsoft_teams/sources/new-chat/new-chat.mjs +++ b/components/microsoft_teams/sources/new-chat/new-chat.mjs @@ -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) { diff --git a/components/microsoft_teams/sources/new-team-member/new-team-member.mjs b/components/microsoft_teams/sources/new-team-member/new-team-member.mjs index 62b0279aaddea..163bb96842a38 100644 --- a/components/microsoft_teams/sources/new-team-member/new-team-member.mjs +++ b/components/microsoft_teams/sources/new-team-member/new-team-member.mjs @@ -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: { diff --git a/components/microsoft_teams/sources/new-team/new-team.mjs b/components/microsoft_teams/sources/new-team/new-team.mjs index c967cfb19cf3a..72325c6c6301f 100644 --- a/components/microsoft_teams/sources/new-team/new-team.mjs +++ b/components/microsoft_teams/sources/new-team/new-team.mjs @@ -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) {