Page MenuHomePhabricator

D7145.id24474.diff
No OneTemporary

D7145.id24474.diff

diff --git a/keyserver/src/responders/message-responders.js b/keyserver/src/responders/message-responders.js
--- a/keyserver/src/responders/message-responders.js
+++ b/keyserver/src/responders/message-responders.js
@@ -27,6 +27,7 @@
import type { TextMessageData } from 'lib/types/messages/text.js';
import { threadPermissions } from 'lib/types/thread-types.js';
import { ServerError } from 'lib/utils/errors.js';
+import { values } from 'lib/utils/objects.js';
import {
tRegex,
tShape,
@@ -316,10 +317,15 @@
}
const { threadID } = targetMessageInfo;
- const [serverThreadInfos, hasPermission] = await Promise.all([
- fetchServerThreadInfos(SQL`t.id = ${threadID}`),
- checkThreadPermission(viewer, threadID, threadPermissions.EDIT_MESSAGE),
- ]);
+
+ const [serverThreadInfos, hasPermission, rawSidebarThreadInfos] =
+ await Promise.all([
+ fetchServerThreadInfos(SQL`t.id = ${threadID}`),
+ checkThreadPermission(viewer, threadID, threadPermissions.EDIT_MESSAGE),
+ fetchServerThreadInfos(
+ SQL`t.parent_thread_id = ${threadID} AND t.source_message = ${targetMessageID}`,
+ ),
+ ]);
const targetMessageThreadInfo = serverThreadInfos.threadInfos[threadID];
if (targetMessageThreadInfo.sourceMessageID === targetMessageID) {
@@ -336,17 +342,33 @@
throw new ServerError('invalid_parameters');
}
+ const time = Date.now();
const messagesData = [];
- const messageData: EditMessageData = {
+ let messageData: EditMessageData = {
type: messageTypes.EDIT_MESSAGE,
threadID,
creatorID: viewer.id,
- time: Date.now(),
+ time,
targetMessageID,
text,
};
messagesData.push(messageData);
+ const sidebarThreadValues = values(rawSidebarThreadInfos.threadInfos);
+ for (const sidebarThreadValue of sidebarThreadValues) {
+ if (sidebarThreadValue && sidebarThreadValue.id) {
+ messageData = {
+ type: messageTypes.EDIT_MESSAGE,
+ threadID: sidebarThreadValue.id,
+ creatorID: viewer.id,
+ time,
+ targetMessageID,
+ text: text,
+ };
+ messagesData.push(messageData);
+ }
+ }
+
const newMessageInfos = await createMessages(viewer, messagesData);
return { newMessageInfos };

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 5:38 PM (8 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2699983
Default Alt Text
D7145.id24474.diff (2 KB)

Event Timeline