Skip to content

Commit

Permalink
Merge pull request #740 from misscoded/736-message-channel-ts
Browse files Browse the repository at this point in the history
Add channel to all MessageEvent interfaces
  • Loading branch information
stevengill authored Jan 12, 2021
2 parents affba2f + 9842d9d commit b4f8336
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/middleware/builtin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,12 @@ const appMentionEvent: AppMentionEvent = {
const botMessageEvent: MessageEvent = {
type: 'message',
subtype: 'bot_message',
channel: 'CHANNEL_ID',
user: 'U1234567',
ts: '123.123',
text: 'this is my message',
bot_id: 'B1234567',
channel_type: 'channel',
};

const noop = () => Promise.resolve(undefined);
Expand Down
34 changes: 21 additions & 13 deletions src/types/events/message-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export interface GenericMessageEvent {
export interface BotMessageEvent {
type: 'message';
subtype: 'bot_message';
channel: string;
channel_type: string;
ts: string;
text: string;
bot_id: string;
Expand All @@ -54,11 +56,14 @@ export interface BotMessageEvent {
user: string;
ts: string;
};
thread_ts?: string;
}

export interface EKMAccessDeniedMessageEvent {
type: 'message';
subtype: 'ekm_access_denied';
channel: string;
channel_type: string;
ts: string;
text: string; // This will not have any meaningful content within
user: 'UREVOKEDU';
Expand All @@ -68,6 +73,7 @@ export interface MeMessageEvent {
type: 'message';
subtype: 'me_message';
channel: string;
channel_type: string;
user: string;
text: string;
ts: string;
Expand All @@ -78,6 +84,7 @@ export interface MessageChangedEvent {
subtype: 'message_changed';
hidden: true;
channel: string;
channel_type: string;
ts: string;
message: MessageEvent;
}
Expand Down Expand Up @@ -110,19 +117,20 @@ export interface MessageRepliedEvent {

export interface ThreadBroadcastMessageEvent {
type: 'message';
subtype: undefined;
message: {
type: 'message';
subtype: 'thread_broadcast';
subtype: 'thread_broadcast';
text: string;
user: string;
ts: string;
thread_ts?: string;
root: (GenericMessageEvent | BotMessageEvent) & {
thread_ts: string;
user: string;
ts: string;
root: (GenericMessageEvent | BotMessageEvent) & {
thread_ts: string;
reply_count: number;
replies: { user: string; ts: string }[];
// TODO: unread_count doesn't appear in any other message event types, is this really the only place its included?
unread_count?: number;
};
reply_count: number;
reply_users_count: number;
latest_reply: string;
reply_users: string[];
};
client_msg_id: string;
channel: string;
event_ts: string;
channel_type: string;
}
2 changes: 1 addition & 1 deletion types-tests/message.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ expectType<void>(app.message(async ({ message }) => {
expectType<MessageEvent>(message);

if (message.subtype === undefined) {
expectError(message.user);
expectError(message.channel_type);
} else if (message.subtype === 'bot_message') {
expectType<BotMessageEvent>(message);
}
Expand Down

0 comments on commit b4f8336

Please sign in to comment.