feat(slack): resolve channel_name and user_name via Slack API#4049
feat(slack): resolve channel_name and user_name via Slack API#4049waleedlatif1 wants to merge 1 commit intostagingfrom
Conversation
…t token is provided
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Both lookups run in parallel with Reviewed by Cursor Bugbot for commit c5240d3. Configure here. |
Greptile SummaryThis PR fixes Confidence Score: 4/5Safe to merge — the change is narrowly scoped, well-guarded against API failures, and has no impact on signature verification or event routing. Logic is straightforward and mirrors the existing helper pattern. The only deduction is the minor sequential latency for reaction events and the absence of automated test coverage for the new helpers. No files require special attention beyond the one minor optimization noted in the inline comment.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/webhooks/providers/slack.ts | Adds fetchSlackChannelName and fetchSlackUserName helpers called in parallel via Promise.all; solid error handling and logging; one minor sequential latency opportunity for reaction events |
Sequence Diagram
sequenceDiagram
participant S as Slack
participant H as slackHandler.formatInput
participant CI as conversations.info
participant UI as users.info
participant RI as reactions.get
S->>H: Webhook event (body + botToken)
H->>H: Extract channel, userId, isReactionEvent
alt isReactionEvent && botToken
H->>RI: fetchSlackMessageText(channel, ts)
RI-->>H: message text
end
alt botToken present
par
H->>CI: fetchSlackChannelName(channel)
and
H->>UI: fetchSlackUserName(userId)
end
CI-->>H: channel_name
UI-->>H: user_name
else no botToken
H->>H: channelName = '', userName = ''
end
H-->>S: FormatInputResult (with channel_name, user_name populated)
Reviews (1): Last reviewed commit: "feat(slack): resolve channel_name and us..." | Re-trigger Greptile
| if (isReactionEvent && channel && messageTs && botToken) { | ||
| text = await fetchSlackMessageText(channel, messageTs, botToken) | ||
| } | ||
|
|
||
| const [channelName, userName] = botToken | ||
| ? await Promise.all([ | ||
| channel ? fetchSlackChannelName(channel, botToken) : Promise.resolve(''), | ||
| userId ? fetchSlackUserName(userId, botToken) : Promise.resolve(''), | ||
| ]) | ||
| : ['', ''] |
There was a problem hiding this comment.
Sequential API calls for reaction events
For reaction events, fetchSlackMessageText is awaited before the Promise.all for channel and user names, resulting in three sequential async round-trips. All three can be parallelized into a single Promise.all, which is especially useful since reactions.get is only needed when isReactionEvent is true.
| if (isReactionEvent && channel && messageTs && botToken) { | |
| text = await fetchSlackMessageText(channel, messageTs, botToken) | |
| } | |
| const [channelName, userName] = botToken | |
| ? await Promise.all([ | |
| channel ? fetchSlackChannelName(channel, botToken) : Promise.resolve(''), | |
| userId ? fetchSlackUserName(userId, botToken) : Promise.resolve(''), | |
| ]) | |
| : ['', ''] | |
| const [text, [channelName, userName]] = await Promise.all([ | |
| isReactionEvent && channel && messageTs && botToken | |
| ? fetchSlackMessageText(channel, messageTs, botToken) | |
| : Promise.resolve(rawEvent?.text as string || ''), | |
| botToken | |
| ? Promise.all([ | |
| channel ? fetchSlackChannelName(channel, botToken) : Promise.resolve(''), | |
| userId ? fetchSlackUserName(userId, botToken) : Promise.resolve(''), | |
| ]) | |
| : Promise.resolve(['', ''] as [string, string]), | |
| ]) |
Summary
channel_nameanduser_nameby callingconversations.infoandusers.infowhen a bot token is providedPromise.allto avoid adding sequential latencyType of Change
Testing
Tested manually
Checklist