Page MenuHomePhabricator

D9330.id31548.diff
No OneTemporary

D9330.id31548.diff

diff --git a/keyserver/src/creators/thread-creator.js b/keyserver/src/creators/thread-creator.js
--- a/keyserver/src/creators/thread-creator.js
+++ b/keyserver/src/creators/thread-creator.js
@@ -9,10 +9,10 @@
generatePendingThreadColor,
generateRandomColor,
} from 'lib/shared/color-utils.js';
+import { messageSpecs } from 'lib/shared/messages/message-specs.js';
import { getThreadTypeParentRequirement } from 'lib/shared/thread-utils.js';
import type { Shape } from 'lib/types/core.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
-import { isInvalidSidebarSource } from 'lib/types/message-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import {
threadTypes,
@@ -195,8 +195,11 @@
validateMembers: { initialMemberIDs, ghostMemberIDs },
} = await promiseAll(checkPromises);
- if (sourceMessage && isInvalidSidebarSource(sourceMessage)) {
- throw new ServerError('invalid_parameters');
+ if (sourceMessage) {
+ const messageSpec = messageSpecs[sourceMessage.type];
+ if (!messageSpec.canBeSidebarSource(sourceMessage)) {
+ throw new ServerError('invalid_parameters');
+ }
}
let { id } = request;
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -10,6 +10,7 @@
import { type ParserRules } from './markdown.js';
import { extractMentionsFromText } from './mention-utils.js';
import { getMessageTitle } from './message-utils.js';
+import { messageSpecs } from './messages/message-specs.js';
import { relationshipBlockedInEitherDirection } from './relationship-utils.js';
import threadWatcher from './thread-watcher.js';
import {
@@ -46,7 +47,6 @@
import { getUserAvatarForThread } from '../shared/avatar-utils.js';
import type { CalendarQuery } from '../types/entry-types.js';
import { messageTypes } from '../types/message-types-enum.js';
-import { isInvalidSidebarSource } from '../types/message-types.js';
import {
type RobotextMessageInfo,
type ComposableMessageInfo,
@@ -1275,11 +1275,12 @@
const messageCreatorUserInfo = useSelector(
state => state.userStore.userInfos[messageInfo.creator.id],
);
+ const messageSpec = messageSpecs[messageInfo.type];
if (
!messageInfo.id ||
threadInfo.sourceMessageID === messageInfo.id ||
- isInvalidSidebarSource(messageInfo)
+ !messageSpec.canBeSidebarSource(messageInfo)
) {
return false;
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 2, 1:41 PM (19 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2607719
Default Alt Text
D9330.id31548.diff (2 KB)

Event Timeline