Skip to content

Commit 6dc74de

Browse files
authored
fix(slack): check the ok field on slack api responses (#294)
1 parent 30eb2b4 commit 6dc74de

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/slack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blink-sdk/slack",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"author": {
55
"name": "Coder",
66
"email": "support@blink.so",

packages/slack/src/message.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,12 @@ export const extractMessagesMetadata = async <
582582
for (const channelId of channelIds) {
583583
channelPromises[channelId] = client.conversations
584584
.info({ channel: channelId })
585-
.then((res) => res.channel);
585+
.then((res) => {
586+
if (!res.ok) {
587+
throw new Error(`Failed to get channel info: ${res.error}`);
588+
}
589+
return res.channel;
590+
});
586591
}
587592

588593
// Fetch team info
@@ -591,9 +596,12 @@ export const extractMessagesMetadata = async <
591596
Promise<TeamInfoResponse["team"] | undefined>
592597
> = {};
593598
for (const teamId of teamIds) {
594-
teamPromises[teamId] = client.team
595-
.info({ team: teamId })
596-
.then((res) => res.team);
599+
teamPromises[teamId] = client.team.info({ team: teamId }).then((res) => {
600+
if (!res.ok) {
601+
throw new Error(`Failed to get team info: ${res.error}`);
602+
}
603+
return res.team;
604+
});
597605
}
598606

599607
// Fetch user info
@@ -602,9 +610,12 @@ export const extractMessagesMetadata = async <
602610
Promise<UsersInfoResponse["user"] | undefined>
603611
> = {};
604612
for (const userId of userIds) {
605-
userPromises[userId] = client.users
606-
.info({ user: userId })
607-
.then((res) => res.user);
613+
userPromises[userId] = client.users.info({ user: userId }).then((res) => {
614+
if (!res.ok) {
615+
throw new Error(`Failed to get user info: ${res.error}`);
616+
}
617+
return res.user;
618+
});
608619
}
609620

610621
// Fetch files

0 commit comments

Comments
 (0)