Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525877
D7141.id24031.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
D7141.id24031.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D7141: [keyserver] Display edited message in the sidebar if the source message is edited
Attached
Detach File
Event Timeline
Log In to Comment