diff --git a/keyserver/src/fetchers/message-fetchers.js b/keyserver/src/fetchers/message-fetchers.js --- a/keyserver/src/fetchers/message-fetchers.js +++ b/keyserver/src/fetchers/message-fetchers.js @@ -721,12 +721,10 @@ > { const requiredIDs = new Set(); for (const row of rows) { - if (row.type === messageTypes.SIDEBAR_SOURCE) { - const content = JSON.parse(row.content); - requiredIDs.add(content.sourceMessageID); - } else if (row.type === messageTypes.TOGGLE_PIN) { - const content = JSON.parse(row.content); - requiredIDs.add(content.targetMessageID); + // parseDerivedMessages should be defined for SIDEBAR_SOURCE and TOGGLE_PIN + const { parseDerivedMessages } = messageSpecs[row.type]; + if (parseDerivedMessages) { + parseDerivedMessages(row, requiredIDs); } } diff --git a/lib/shared/messages/message-spec.js b/lib/shared/messages/message-spec.js --- a/lib/shared/messages/message-spec.js +++ b/lib/shared/messages/message-spec.js @@ -116,6 +116,7 @@ +canBeSidebarSource: boolean, +canBePinned: boolean, +canBeRenderedOnItsOwn?: boolean, + +parseDerivedMessages?: (row: Object, requiredIDs: Set) => void, +useCreationSideEffectsFunc?: () => CreationSideEffectsFunc, +validator: TType, }; 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 @@ -176,5 +176,10 @@ canBePinned: false, + parseDerivedMessages(row: Object, requiredIDs: Set): void { + const content = JSON.parse(row.content); + requiredIDs.add(content.sourceMessageID); + }, + validator: rawSidebarSourceMessageInfoValidator, }); diff --git a/lib/shared/messages/toggle-pin-message-spec.js b/lib/shared/messages/toggle-pin-message-spec.js --- a/lib/shared/messages/toggle-pin-message-spec.js +++ b/lib/shared/messages/toggle-pin-message-spec.js @@ -159,5 +159,10 @@ canBePinned: false, + parseDerivedMessages(row: Object, requiredIDs: Set): void { + const content = JSON.parse(row.content); + requiredIDs.add(content.targetMessageID); + }, + validator: rawTogglePinMessageInfoValidator, });