@pipedream/microsoft_teams 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/create-channel/create-channel.mjs +1 -1
- package/actions/list-channels/list-channels.mjs +1 -1
- package/actions/list-shifts/list-shifts.mjs +1 -1
- package/actions/send-channel-message/send-channel-message.mjs +1 -1
- package/actions/send-chat-message/send-chat-message.mjs +1 -1
- package/microsoft_teams.app.mjs +66 -2
- package/package.json +1 -1
- package/sources/new-channel/new-channel.mjs +1 -1
- package/sources/new-channel-message/new-channel-message.mjs +1 -1
- package/sources/new-chat/new-chat.mjs +1 -1
- package/sources/new-chat-message/new-chat-message.mjs +1 -1
- package/sources/new-team/new-team.mjs +1 -1
- package/sources/new-team-member/new-team-member.mjs +1 -1
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Create Channel",
|
|
6
6
|
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)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.7",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftTeams,
|
|
11
11
|
teamId: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "List Channels",
|
|
6
6
|
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)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.7",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftTeams,
|
|
11
11
|
teamId: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "List Shifts",
|
|
6
6
|
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)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftTeams,
|
|
11
11
|
teamId: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Send Channel Message",
|
|
6
6
|
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)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.7",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftTeams,
|
|
11
11
|
teamId: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Send Chat Message",
|
|
6
6
|
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)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.7",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftTeams,
|
|
11
11
|
chatId: {
|
package/microsoft_teams.app.mjs
CHANGED
|
@@ -58,16 +58,64 @@ export default {
|
|
|
58
58
|
chat: {
|
|
59
59
|
type: "string",
|
|
60
60
|
label: "Chat",
|
|
61
|
-
description: "Team Chat
|
|
61
|
+
description: "Team Chat (internal and external contacts)",
|
|
62
62
|
async options({ prevContext }) {
|
|
63
63
|
const response = prevContext.nextLink
|
|
64
64
|
? await this.makeRequest({
|
|
65
65
|
path: prevContext.nextLink,
|
|
66
66
|
})
|
|
67
67
|
: await this.listChats();
|
|
68
|
+
|
|
69
|
+
const myTenantId = await this.getAuthenticatedUserTenant();
|
|
68
70
|
const options = [];
|
|
71
|
+
|
|
72
|
+
this._userCache = this._userCache || new Map();
|
|
73
|
+
|
|
69
74
|
for (const chat of response.value) {
|
|
70
|
-
const
|
|
75
|
+
const messages = await this.makeRequest({
|
|
76
|
+
path: `/chats/${chat.id}/messages?$top=50`,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const members = await Promise.all(chat.members.map(async (member) => {
|
|
80
|
+
const cacheKey = `user_${member.userId}`;
|
|
81
|
+
let displayName = member.displayName || this._userCache.get(cacheKey);
|
|
82
|
+
|
|
83
|
+
if (!displayName) {
|
|
84
|
+
try {
|
|
85
|
+
if (messages?.value?.length > 0) {
|
|
86
|
+
const userMessage = messages.value.find((msg) =>
|
|
87
|
+
msg.from?.user?.id === member.userId);
|
|
88
|
+
if (userMessage?.from?.user?.displayName) {
|
|
89
|
+
displayName = userMessage.from.user.displayName;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!displayName) {
|
|
94
|
+
const userDetails = await this.makeRequest({
|
|
95
|
+
path: `/users/${member.userId}`,
|
|
96
|
+
});
|
|
97
|
+
displayName = userDetails.displayName;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this._userCache.set(cacheKey, displayName);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
if (err.statusCode === 404) {
|
|
103
|
+
displayName = "User Not Found";
|
|
104
|
+
} else if (err.statusCode === 403) {
|
|
105
|
+
displayName = "Access Denied";
|
|
106
|
+
} else {
|
|
107
|
+
displayName = "Unknown User";
|
|
108
|
+
}
|
|
109
|
+
console.error(`Failed to fetch user details for ${member.userId}:`, err);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const isExternal = member.tenantId !== myTenantId || !member.tenantId;
|
|
114
|
+
return isExternal
|
|
115
|
+
? `${displayName} (External)`
|
|
116
|
+
: displayName;
|
|
117
|
+
}));
|
|
118
|
+
|
|
71
119
|
options.push({
|
|
72
120
|
label: members.join(", "),
|
|
73
121
|
value: chat.id,
|
|
@@ -144,6 +192,22 @@ export default {
|
|
|
144
192
|
: reduction;
|
|
145
193
|
}, api);
|
|
146
194
|
},
|
|
195
|
+
async getAuthenticatedUserTenant() {
|
|
196
|
+
try {
|
|
197
|
+
const { value } = await this.client()
|
|
198
|
+
.api("/organization")
|
|
199
|
+
.get();
|
|
200
|
+
|
|
201
|
+
if (!value || value.length === 0) {
|
|
202
|
+
throw new Error("No organization found");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return value[0].id;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error("Failed to fetch tenant ID:", error);
|
|
208
|
+
throw new Error("Unable to determine tenant ID");
|
|
209
|
+
}
|
|
210
|
+
},
|
|
147
211
|
async authenticatedUserId() {
|
|
148
212
|
const { id } = await this.client()
|
|
149
213
|
.api("/me")
|
package/package.json
CHANGED