Skip to content

Commit

Permalink
Add items property for working reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Aug 16, 2019
1 parent bba7b98 commit ce30945
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/BaseSlackHandler.ts
Expand Up @@ -55,6 +55,11 @@ export interface ISlackEventMessageAttachment {
}

export interface ISlackMessageEvent extends ISlackEvent {
item?: {
type: string;
channel: string;
ts: string;
};
subtype: string;
user?: string;
bot_id?: string;
Expand Down
12 changes: 11 additions & 1 deletion src/SlackEventHandler.ts
Expand Up @@ -147,7 +147,17 @@ export class SlackEventHandler extends BaseSlackHandler {
* @param ISlackEventParamsMessage The slack message event to handle.
*/
private async handleMessageEvent(params: ISlackEventParamsMessage) {
const room = this.main.getRoomBySlackChannelId(params.event.channel) as BridgedRoom;
// Reactions use an item key for storing the message and channel, because
// slack *loves* consistency.
let channelId: string;
if (params.event.channel) {
channelId = params.event.channel;
} else if (params.event.item) {
channelId = params.event.item.channel;
} else {
throw Error("Channel not given in event, we possibly cannot handle this event.");
}
const room = this.main.getRoomBySlackChannelId(channelId) as BridgedRoom;
if (!room) { throw new Error("unknown_channel"); }

if (params.event.subtype === "bot_message" &&
Expand Down

0 comments on commit ce30945

Please sign in to comment.