Skip to content

Commit d4ae64c

Browse files
fix(slack): v1 keeps slack_webhook trigger subblocks; handle object-form event channels
- v1 spread had been swapped to slack_oauth's trigger subblocks (shared with v2), leaving its slack_webhook deploy path without signing-secret config (Bugbot high). v1 now carries the legacy trigger set again; v2 swaps them for slack_oauth's. - resolveSlackEventChannel reads channel.id for channel_created/channel_rename payloads, so channel filters no longer drop every rename event.
1 parent 8d40d3f commit d4ae64c

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

apps/sim/blocks/blocks/slack.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ Return ONLY the integer Unix timestamp - no explanations, no quotes, no extra te
14531453
},
14541454
required: true,
14551455
},
1456-
...getTrigger('slack_oauth').subBlocks,
1456+
...getTrigger('slack_webhook').subBlocks,
14571457
],
14581458
tools: {
14591459
access: [
@@ -2660,11 +2660,15 @@ const SLACK_CUSTOM_BOT_SUBBLOCKS: SubBlockConfig[] = [
26602660
},
26612661
]
26622662

2663+
const SLACK_WEBHOOK_TRIGGER_SUBBLOCK_IDS = new Set(
2664+
getTrigger('slack_webhook').subBlocks.map((sb) => sb.id)
2665+
)
2666+
26632667
/**
26642668
* slack_v2 — the go-forward Slack action block. Identical operations, tools, and
26652669
* outputs to v1 (shared by reference), but the "Custom Bot" auth method selects
26662670
* a reusable bot credential set up once, instead of pasting a raw token. Also
2667-
* hosts the native Slack trigger so it surfaces once.
2671+
* hosts the redesigned slack_oauth trigger (v1 keeps the legacy slack_webhook).
26682672
*/
26692673
export const SlackV2Block: BlockConfig<SlackResponse> = {
26702674
...SlackBlock,
@@ -2675,11 +2679,17 @@ export const SlackV2Block: BlockConfig<SlackResponse> = {
26752679
// self-host). At GA: drop this flag, add SlackV2BlockMeta + docs, and set
26762680
// hideFromToolbar on v1.
26772681
preview: true,
2678-
subBlocks: SlackBlock.subBlocks.flatMap((sb) => {
2679-
if (sb.id === 'botToken') return []
2680-
if (sb.id === 'authMethod') return [sb, ...SLACK_CUSTOM_BOT_SUBBLOCKS]
2681-
return [sb]
2682-
}),
2682+
subBlocks: [
2683+
...SlackBlock.subBlocks.flatMap((sb) => {
2684+
// Drop the legacy paste-secret trigger config (v1 hosts slack_webhook)
2685+
// and v1's raw bot-token auth field — the trigger set includes an
2686+
// id-colliding 'botToken', so the set check covers both.
2687+
if (SLACK_WEBHOOK_TRIGGER_SUBBLOCK_IDS.has(sb.id)) return []
2688+
if (sb.id === 'authMethod') return [sb, ...SLACK_CUSTOM_BOT_SUBBLOCKS]
2689+
return [sb]
2690+
}),
2691+
...getTrigger('slack_oauth').subBlocks,
2692+
],
26832693
triggers: {
26842694
enabled: true,
26852695
available: ['slack_oauth'],

apps/sim/lib/webhooks/providers/slack.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ describe('shouldSkipSlackTriggerEvent', () => {
437437
expect(fires({ eventType: 'reaction_added', bot_user_id: 'U_OTHER' }, event)).toBe(true)
438438
})
439439

440+
it('matches the channel filter for object-form channels (channel_rename)', () => {
441+
// channel_created / channel_rename deliver `channel` as an object, not a string.
442+
const rename = {
443+
type: 'channel_rename',
444+
channel: { id: 'C1', name: 'renamed-channel', created: 1 },
445+
}
446+
expect(fires({ eventType: 'channel_rename', channelFilter: ['C1'] }, rename)).toBe(true)
447+
expect(fires({ eventType: 'channel_rename', channelFilter: ['C2'] }, rename)).toBe(false)
448+
})
449+
440450
it('applies the emoji filter to reaction events', () => {
441451
const event = {
442452
type: 'reaction_added',

apps/sim/lib/webhooks/providers/slack.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ export function resolveSlackEventChannel(
499499
): string | undefined {
500500
if (!event) return undefined
501501
if (typeof event.channel === 'string') return event.channel
502+
// channel_created / channel_rename deliver `channel` as an object.
503+
if (isRecordLike(event.channel) && typeof event.channel.id === 'string') {
504+
return event.channel.id
505+
}
502506
const item = event.item as Record<string, unknown> | undefined
503507
if (typeof item?.channel === 'string') return item.channel
504508
return typeof event.channel_id === 'string' ? event.channel_id : undefined

0 commit comments

Comments
 (0)