|
1 | 1 | import { Logger } from '@gitbook/runtime';
|
2 | 2 |
|
| 3 | +import type { SlashEvent } from './commands'; |
3 | 4 | import { notifyOnlySupportedThreads, queryLens, saveThread } from '../actions';
|
4 | 5 | import { SlackRuntimeContext } from '../configuration';
|
5 | 6 | import { isSaveThreadMessage, stripBotName } from '../utils';
|
6 |
| -import type { SlashEvent } from './commands'; |
7 | 7 |
|
8 | 8 | const logger = Logger('slack:api');
|
9 | 9 |
|
@@ -40,9 +40,10 @@ export async function queryLensSlashHandler(slashEvent: SlashEvent, context: Sla
|
40 | 40 | export async function messageEventHandler(eventPayload: any, context: SlackRuntimeContext) {
|
41 | 41 | // pull out required params from the slashEvent for queryLens
|
42 | 42 | const { type, text, bot_id, thread_ts, channel, user, team } = eventPayload.event;
|
| 43 | + const isExternalChannel = eventPayload.is_ext_shared_channel; |
43 | 44 |
|
44 | 45 | // check for bot_id so that the bot doesn't trigger itself
|
45 |
| - if (['message', 'app_mention'].includes(type) && !bot_id) { |
| 46 | + if (['message', 'app_mention'].includes(type) && !bot_id && !isExternalChannel) { |
46 | 47 | // strip out the bot-name in the mention and account for user mentions within the query
|
47 | 48 | // @ts-ignore
|
48 | 49 | const parsedQuery = stripBotName(text, eventPayload.authorizations[0]?.user_id);
|
@@ -73,9 +74,10 @@ export async function messageEventHandler(eventPayload: any, context: SlackRunti
|
73 | 74 | export async function appMentionEventHandler(eventPayload: any, context: SlackRuntimeContext) {
|
74 | 75 | // pull out required params from the slashEvent for queryLens
|
75 | 76 | const { type, text, bot_id, thread_ts, channel, user, team } = eventPayload.event;
|
| 77 | + const isExternalChannel = eventPayload.is_ext_shared_channel; |
76 | 78 |
|
77 | 79 | // check for bot_id so that the bot doesn't trigger itself
|
78 |
| - if (['message', 'app_mention'].includes(type) && !bot_id) { |
| 80 | + if (['message', 'app_mention'].includes(type) && !bot_id && !isExternalChannel) { |
79 | 81 | // strip out the bot-name in the mention and account for user mentions within the query
|
80 | 82 | // @ts-ignore
|
81 | 83 | const parsedMessage = stripBotName(text, eventPayload.authorizations[0]?.user_id);
|
|
0 commit comments