Skip to content

Commit

Permalink
fix(slack): message event
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX committed Jul 13, 2023
1 parent 2077591 commit 96488ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions adapters/slack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"dependencies": {
"@slack/types": "^2.8.0",
"form-data": "^4.0.0",
"seratch-slack-types": "^0.8.0"
"form-data": "^4.0.0"
}
}
1 change: 0 additions & 1 deletion adapters/slack/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { adaptChannel, adaptGuild, adaptMessage, adaptUser, AuthTestResponse } f
import { SlackMessageEncoder } from './message'
import { GenericMessageEvent, SlackChannel, SlackTeam, SlackUser } from './types'
import FormData from 'form-data'
import * as WebApi from 'seratch-slack-types/web-api'
import { Internal, Token } from './types/internal'

export class SlackBot<T extends SlackBot.Config = SlackBot.Config> extends Bot<T> {
Expand Down
7 changes: 5 additions & 2 deletions adapters/slack/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ export async function adaptSession(bot: SlackBot, payload: EnvelopedEvent<SlackE
session.channelId = input.channel
await adaptMessage(bot, input as unknown as GenericMessageEvent, session)
}
if (input.subtype === 'message_deleted') adaptMessageDeleted(bot, input as unknown as MessageDeletedEvent, session)
if (input.subtype === 'message_changed') {
else if (input.subtype === 'message_deleted') adaptMessageDeleted(bot, input as unknown as MessageDeletedEvent, session)
else if (input.subtype === 'message_changed') {
const evt = input as unknown as MessageChangedEvent
if (evt.message.subtype === 'thread_broadcast') return
session.type = 'message-updated'
// @ts-ignore
session.guildId = payload.team_id
session.isDirect = input.channel_type === 'im'
session.channelId = input.channel
await adaptMessage(bot, evt.message, session)
} else {
return
}
} else if (payload.event.type === 'channel_left') {
session.type = 'channel-removed'
Expand Down

0 comments on commit 96488ef

Please sign in to comment.