Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3245264
D9542.id32227.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9542.id32227.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D9542: [keyserver/lib] Introduce a parseDerivedMessages function in the message specs
Attached
Detach File
Event Timeline
Log In to Comment