Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update message types #782

Merged
merged 6 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/middleware/builtin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ const botMessageEvent: MessageEvent = {
type: 'message',
subtype: 'bot_message',
channel: 'CHANNEL_ID',
event_ts: '123.123',
user: 'U1234567',
ts: '123.123',
text: 'this is my message',
Expand Down
102 changes: 95 additions & 7 deletions src/types/events/message-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ export type MessageEvent =
export interface GenericMessageEvent {
type: 'message';
subtype: undefined;
event_ts: string;
team?: string;
channel: string;
user: string;
text?: string;
ts: string;
thread_ts?: string;
channel_type: channelTypes;
attachments?: MessageAttachment[];
blocks?: (KnownBlock | Block)[];
files?: File[];
edited?: {
user: string;
ts: string;
};
client_msg_id?: string;
parent_user_id?: string;

// TODO: optional types that maybe should flow into other subtypes?
is_starred?: boolean;
Expand All @@ -37,8 +44,9 @@ export interface GenericMessageEvent {
export interface BotMessageEvent {
type: 'message';
subtype: 'bot_message';
event_ts: string;
channel: string;
channel_type: string;
channel_type: channelTypes;
ts: string;
text: string;
bot_id: string;
Expand All @@ -62,8 +70,9 @@ export interface BotMessageEvent {
export interface EKMAccessDeniedMessageEvent {
type: 'message';
subtype: 'ekm_access_denied';
event_ts: string;
channel: string;
channel_type: string;
channel_type: channelTypes;
ts: string;
text: string; // This will not have any meaningful content within
user: 'UREVOKEDU';
Expand All @@ -72,8 +81,9 @@ export interface EKMAccessDeniedMessageEvent {
export interface MeMessageEvent {
type: 'message';
subtype: 'me_message';
event_ts: string;
channel: string;
channel_type: string;
channel_type: channelTypes;
user: string;
text: string;
ts: string;
Expand All @@ -82,28 +92,34 @@ export interface MeMessageEvent {
export interface MessageChangedEvent {
type: 'message';
subtype: 'message_changed';
event_ts: string;
hidden: true;
channel: string;
channel_type: string;
channel_type: channelTypes;
ts: string;
message: MessageEvent;
previous_message: MessageEvent;
}

export interface MessageDeletedEvent {
type: 'message';
subtype: 'message_deleted';
event_ts: string;
hidden: true;
channel: string;
channel_type: channelTypes;
ts: string;
deleted_ts: string;
previous_message: MessageEvent;
}

export interface MessageRepliedEvent {
type: 'message';
subtype: 'message_replied';
event_ts: string;
hidden: true;
channel: string;
event_ts: string;
channel_type: channelTypes;
ts: string;
message: MessageEvent & {
// TODO: should this be the union of all message events with type 'message'?
Expand All @@ -118,7 +134,10 @@ export interface MessageRepliedEvent {
export interface ThreadBroadcastMessageEvent {
type: 'message';
subtype: 'thread_broadcast';
event_ts: string;
text: string;
attachments?: MessageAttachment[];
blocks?: (KnownBlock | Block)[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, attachments is missing.

user: string;
ts: string;
thread_ts?: string;
Expand All @@ -131,6 +150,75 @@ export interface ThreadBroadcastMessageEvent {
};
client_msg_id: string;
channel: string;
event_ts: string;
channel_type: string;
channel_type: channelTypes;
}

export type channelTypes = 'channel' | 'group' | 'im' | 'mpim' | 'app_home';

interface File {
id: string;
created: number;
name: string | null;
title: string | null;
mimetype: string;
filetype: string;
pretty_type: string;
user?: string;
editable: boolean;
size: number;
mode: 'hosted' | 'external' | 'snippet' | 'post';
is_external: boolean;
external_type: string | null;
is_public: boolean;
public_url_shared: boolean;
display_as_bot: boolean;
username: string | null;

// Authentication required
url_private?: string;
url_private_download?: string;

// Thumbnails (authentication still required)
thumb_64?: string;
thumb_80?: string;
thumb_160?: string;
thumb_360?: string;
thumb_360_w?: number;
thumb_360_h?: number;
thumb_360_gif?: string;
thumb_480?: string;
thumb_720?: string;
thumb_960?: string;
thumb_1024?: string;
permalink: string;
permalink_public?: string;
edit_link?: string;
image_exif_rotation?: number;
original_w?: number;
original_h?: number;
deanimate_gif?: string;

// Posts
preview?: string;
preview_highlight?: string;
lines?: string;
lines_more?: string;
preview_is_truncated?: boolean;
has_rich_preview?: boolean;

shares?: {
[key: string]: any;
};
channels: string[] | null;
groups: string[] | null;
users?: string[];
pinned_to?: string[];
reactions?: {
[key: string]: any;
}[];
is_starred?: boolean;
num_stars?: number;

initial_comment?: string;
comments_count?: string;
}