Page MenuHomePhabricator

D9542.id32227.diff
No OneTemporary

D9542.id32227.diff

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,13 +721,9 @@
> {
const requiredIDs = new Set<string>();
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];
+ parseDerivedMessages?.(row, requiredIDs);
}
const messagesByID = new Map<
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,
+canBeRenderedIndependently?: boolean,
+ +parseDerivedMessages?: (row: Object, requiredIDs: Set<string>) => void,
+useCreationSideEffectsFunc?: () => CreationSideEffectsFunc<RawInfo>,
+validator: TType<RawInfo>,
};
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,16 @@
canBePinned: false,
+ parseDerivedMessages(row: Object, requiredIDs: Set<string>): void {
+ try {
+ const content = JSON.parse(row.content);
+ requiredIDs.add(content.sourceMessageID);
+ } catch (e) {
+ console.error(
+ `Error parsing content of message with id ${row.id}: ${e.message}`,
+ );
+ }
+ },
+
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,16 @@
canBePinned: false,
+ parseDerivedMessages(row: Object, requiredIDs: Set<string>): void {
+ try {
+ const content = JSON.parse(row.content);
+ requiredIDs.add(content.targetMessageID);
+ } catch (e) {
+ console.error(
+ `Error parsing content of message with id ${row.id}: ${e.message}`,
+ );
+ }
+ },
+
validator: rawTogglePinMessageInfoValidator,
});

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 15, 5:30 PM (21 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2494925
Default Alt Text
D9542.id32227.diff (2 KB)

Event Timeline