Details
Flow
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Only some of the message types can be sidebar sources. Can we keep enforcing it using validators?
According to our source of truth (specs) the following message types can be sidebar sources:
- AddMembers
- ChangeRole
- ChangeSettings
- CreateEntry
- CreateSidebar
- CreateSubthread
- CreateThread
- DeleteEntry
- EditEntry
- JoinThread
- LeaveThread
- MultimediaMessage
- RemoveMembers
- RestoreEntry
- TextMessage
- UnsupportedMessage
- UpdateRelationship
And the following types cannot be sidebar sources:
- DeleteMessage
- EditMessage
- ReactionMessage
- SidebarSourceMessage
- TogglePinMessage <— important!
ValidRawSidebarSourceMessageInfo looks like this:
export type ValidRawSidebarSourceMessageInfo = | RawTextMessageInfo | RawCreateThreadMessageInfo | RawAddMembersMessageInfo | RawCreateSubthreadMessageInfo | RawChangeSettingsMessageInfo | RawRemoveMembersMessageInfo | RawChangeRoleMessageInfo | RawLeaveThreadMessageInfo | RawJoinThreadMessageInfo | RawCreateEntryMessageInfo | RawEditEntryMessageInfo | RawDeleteEntryMessageInfo | RawRestoreEntryMessageInfo | RawImagesMessageInfo | RawMediaMessageInfo | RawLegacyUpdateRelationshipMessageInfo | RawCreateSidebarMessageInfo | RawUnsupportedMessageInfo | RawUpdateRelationshipMessageInfo;
and contains all valid sources and doesn’t contain any invalid sources (RawImagesMessageInfo | RawMediaMessageInfo = MultimediaMessage and RawLegacyUpdateRelationshipMessageInfo | RawUpdateRelationshipMessageInfo = UpdateRelationship)
However the validators before the change accepted invalid sources:
sourceMessage: t.maybe(
t.union([
rawComposableMessageInfoValidator,
rawRobotextMessageInfoValidator,
])
)expand rawRobotextMessageInfoValidator:
const rawRobotextMessageInfoValidator = t.union([ rawCreateThreadMessageInfoValidator, rawAddMembersMessageInfoValidator, rawCreateSubthreadMessageInfoValidator, rawChangeSettingsMessageInfoValidator, rawRemoveMembersMessageInfoValidator, rawChangeRoleMessageInfoValidator, rawLeaveThreadMessageInfoValidator, rawJoinThreadMessageInfoValidator, rawCreateEntryMessageInfoValidator, rawEditEntryMessageInfoValidator, rawDeleteEntryMessageInfoValidator, rawRestoreEntryMessageInfoValidator, rawLegacyUpdateRelationshipMessageInfoValidator, rawCreateSidebarMessageInfoValidator, rawUnsupportedMessageInfoValidator, rawTogglePinMessageInfoValidator, <— there is it! the invalid message type! rawUpdateRelationshipMessageInfoValidator, ]);
The validator after this change is the same as expanding unions (rawComposableMessageInfoValidator and rawRobotextMessageInfoValidator) + deleting rawTogglePinMessageInfoValidator and it corresponds to ValidRawSidebarSourceMessageInfo type so it should be correct