Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525837
D7632.id25830.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7632.id25830.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
@@ -24,6 +24,7 @@
defaultMaxMessageAge,
type FetchPinnedMessagesRequest,
type FetchPinnedMessagesResult,
+ isMessageSidebarSourceReactionOrEdit,
} from 'lib/types/message-types.js';
import { threadPermissions } from 'lib/types/thread-types.js';
import { ServerError } from 'lib/utils/errors.js';
@@ -742,13 +743,12 @@
for (const message of messages) {
let { rawMessageInfo } = message;
+ invariant(
+ !isMessageSidebarSourceReactionOrEdit(rawMessageInfo),
+ 'SIDEBAR_SOURCE or TOGGLE_PIN should not point to a ' +
+ 'SIDEBAR_SOURCE, REACTION or EDIT_MESSAGE',
+ );
if (rawMessageInfo.id) {
- invariant(
- rawMessageInfo.type !== messageTypes.SIDEBAR_SOURCE &&
- rawMessageInfo.type !== messageTypes.REACTION &&
- rawMessageInfo.type !== messageTypes.EDIT_MESSAGE,
- 'SIDEBAR_SOURCE should not point to a SIDEBAR_SOURCE, REACTION or EDIT_MESSAGE',
- );
const editedContent = edits.get(rawMessageInfo.id);
if (editedContent && rawMessageInfo.type === messageTypes.TEXT) {
rawMessageInfo = {
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
@@ -10,13 +10,14 @@
} from './message-spec.js';
import { joinResult } from './utils.js';
import type { PlatformDetails } from '../../types/device-types.js';
-import type {
- RawSidebarSourceMessageInfo,
- SidebarSourceMessageData,
- SidebarSourceMessageInfo,
- ClientDBMessageInfo,
+import {
+ type RawSidebarSourceMessageInfo,
+ type SidebarSourceMessageData,
+ type SidebarSourceMessageInfo,
+ type ClientDBMessageInfo,
+ messageTypes,
+ isMessageSidebarSourceReactionOrEdit,
} from '../../types/message-types.js';
-import { messageTypes } from '../../types/message-types.js';
import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported.js';
import type { NotifTexts } from '../../types/notif-types.js';
import type { RelativeUserInfo } from '../../types/user-types.js';
@@ -106,10 +107,7 @@
rawMessageInfo.sourceMessage,
);
invariant(
- sourceMessage &&
- sourceMessage.type !== messageTypes.SIDEBAR_SOURCE &&
- sourceMessage.type !== messageTypes.REACTION &&
- sourceMessage.type !== messageTypes.EDIT_MESSAGE,
+ sourceMessage && !isMessageSidebarSourceReactionOrEdit(sourceMessage),
'Sidebars can not be created from SIDEBAR SOURCE, REACTION or EDIT MESSAGE',
);
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
@@ -214,6 +214,16 @@
return messageData.localID;
}
+export function isMessageSidebarSourceReactionOrEdit(
+ message: RawMessageInfo | MessageInfo,
+): boolean %checks {
+ return (
+ message.type === messageTypes.SIDEBAR_SOURCE ||
+ message.type === messageTypes.REACTION ||
+ message.type === messageTypes.EDIT_MESSAGE
+ );
+}
+
const mediaMessageTypes = new Set([
messageTypes.IMAGES,
messageTypes.MULTIMEDIA,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 6:29 PM (7 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700766
Default Alt Text
D7632.id25830.diff (3 KB)
Attached To
Mode
D7632: [keyserver, lib] extract checking if message is an edit, reaction or sidebar_source
Attached
Detach File
Event Timeline
Log In to Comment