Page MenuHomePhabricator

D7141.id24031.diff
No OneTemporary

D7141.id24031.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
@@ -33,7 +33,10 @@
} from './role-creator.js';
import type { UpdatesForCurrentSession } from './update-creator.js';
import { dbQuery, SQL } from '../database/database.js';
-import { fetchMessageInfoByID } from '../fetchers/message-fetchers.js';
+import {
+ fetchLatestEditMessageContentByID,
+ fetchMessageInfoByID,
+} from '../fetchers/message-fetchers.js';
import {
determineThreadAncestry,
personalThreadQuery,
@@ -443,6 +446,24 @@
},
},
);
+ // Add latest edit message of sourceMessage to the sidebar
+ if (sourceMessageID) {
+ const editMessageContent = await fetchLatestEditMessageContentByID(
+ sourceMessageID,
+ );
+ if (editMessageContent) {
+ const editedText = editMessageContent.text;
+ const messageData = {
+ type: messageTypes.EDIT_MESSAGE,
+ threadID: id,
+ creatorID: sourceMessage.creatorID,
+ time: time,
+ targetMessageID: sourceMessageID,
+ text: editedText,
+ };
+ messageDatas.push(messageData);
+ }
+ }
}
if (
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
@@ -15,6 +15,7 @@
type RawRobotextMessageInfo,
messageTypes,
type MessageType,
+ type EditMessageContent,
assertMessageType,
type MessageSelectionCriteria,
type MessageTruncationStatus,
@@ -645,7 +646,7 @@
async function fetchMessageRowsByIDs(messageIDs: $ReadOnlyArray<string>) {
const query = SQL`
- SELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,
+ SELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,
m.user AS creatorID, m.target_message as targetMessageID,
stm.permissions AS subthread_permissions, up.id AS uploadID,
up.type AS uploadType, up.secret AS uploadSecret, up.extra AS uploadExtra
@@ -721,6 +722,23 @@
return result[0].count;
}
+async function fetchLatestEditMessageContentByID(
+ messageID: string,
+): Promise<?EditMessageContent> {
+ const latestEditedMessageQuery = SQL`
+ SELECT content
+ FROM messages
+ WHERE target_message = ${messageID}
+ AND type = ${messageTypes.EDIT_MESSAGE}
+ ORDER BY id DESC LIMIT 1`;
+ const [editedContent] = await dbQuery(latestEditedMessageQuery);
+ if (editedContent.length === 0) {
+ return null;
+ }
+ const jsonContent = JSON.parse(editedContent[0].content);
+ return jsonContent;
+}
+
export {
fetchCollapsableNotifs,
fetchMessageInfos,
@@ -730,4 +748,5 @@
fetchMessageInfoForEntryAction,
fetchMessageInfoByID,
fetchThreadMessagesCount,
+ fetchLatestEditMessageContentByID,
};
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
@@ -575,6 +575,10 @@
export type EditMessagePayload = SendEditMessageResponse;
export type SendEditMessageResult = SendEditMessageResponse;
+export type EditMessageContent = {
+ +text: string,
+};
+
// Used for the message info included in log-in type actions
export type GenericMessagesResult = {
+messageInfos: RawMessageInfo[],

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 6:37 PM (8 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700791
Default Alt Text
D7141.id24031.diff (3 KB)

Event Timeline