diff --git a/lib/shared/messages/sidebar-source-message-spec.js b/lib/shared/messages/sidebar-source-message-spec.js --- a/lib/shared/messages/sidebar-source-message-spec.js +++ b/lib/shared/messages/sidebar-source-message-spec.js @@ -86,6 +86,12 @@ `${content.sourceMessageID} which is not present in the database`, ); } + + invariant( + sourceMessage && !isInvalidSidebarSource(sourceMessage), + 'SIDEBAR_SOURCE should not point to an invalid message type', + ); + return { type: messageTypes.SIDEBAR_SOURCE, id: row.id.toString(), diff --git a/lib/types/message-types.js b/lib/types/message-types.js --- a/lib/types/message-types.js +++ b/lib/types/message-types.js @@ -210,12 +210,32 @@ // Raw*MessageInfo = used by server, and contained in client's local store // *MessageInfo = used by client in UI code +export type ValidSidebarSourceMessageInfo = + | RawTextMessageInfo + | RawCreateThreadMessageInfo + | RawAddMembersMessageInfo + | RawCreateSubthreadMessageInfo + | RawChangeSettingsMessageInfo + | RawRemoveMembersMessageInfo + | RawChangeRoleMessageInfo + | RawLeaveThreadMessageInfo + | RawJoinThreadMessageInfo + | RawCreateEntryMessageInfo + | RawEditEntryMessageInfo + | RawDeleteEntryMessageInfo + | RawRestoreEntryMessageInfo + | RawImagesMessageInfo + | RawMediaMessageInfo + | RawUpdateRelationshipMessageInfo + | RawCreateSidebarMessageInfo + | RawUnsupportedMessageInfo; + export type SidebarSourceMessageData = { +type: 17, +threadID: string, +creatorID: string, +time: number, - +sourceMessage?: RawComposableMessageInfo | RawRobotextMessageInfo, + +sourceMessage?: ValidSidebarSourceMessageInfo, }; export type MessageData =