Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3349043
D12807.id42554.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12807.id42554.diff
View Options
diff --git a/lib/shared/dm-ops/edit-message-spec.js b/lib/shared/dm-ops/edit-message-spec.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/dm-ops/edit-message-spec.js
@@ -0,0 +1,46 @@
+// @flow
+
+import uuid from 'uuid';
+
+import type { DMOperationSpec } from './dm-op-spec.js';
+import type { DMSendEditMessageOperation } from '../../types/dm-ops.js';
+import { messageTypes } from '../../types/message-types-enum.js';
+import { updateTypes } from '../../types/update-types-enum.js';
+import type { ClientUpdateInfo } from '../../types/update-types.js';
+
+const sendEditMessageSpec: DMOperationSpec<DMSendEditMessageOperation> =
+ Object.freeze({
+ processDMOperation: async (
+ dmOperation: DMSendEditMessageOperation,
+ viewerID: string,
+ ) => {
+ const { threadID, creatorID, time, messageID, targetMessageID, text } =
+ dmOperation;
+ const reactionMessage = {
+ type: messageTypes.EDIT_MESSAGE,
+ id: messageID,
+ threadID,
+ creatorID,
+ time,
+ targetMessageID,
+ text,
+ };
+
+ const updateInfos: Array<ClientUpdateInfo> = [];
+ if (creatorID !== viewerID) {
+ updateInfos.push({
+ type: updateTypes.UPDATE_THREAD_READ_STATUS,
+ id: uuid.v4(),
+ time,
+ threadID,
+ unread: true,
+ });
+ }
+ return {
+ rawMessageInfos: [reactionMessage],
+ updateInfos,
+ };
+ },
+ });
+
+export { sendEditMessageSpec };
diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js
--- a/lib/types/dm-ops.js
+++ b/lib/types/dm-ops.js
@@ -17,6 +17,7 @@
CREATE_SIDEBAR: 'create_sidebar',
SEND_TEXT_MESSAGE: 'send_text_message',
SEND_REACTION_MESSAGE: 'send_reaction_message',
+ SEND_EDIT_MESSAGE: 'send_edit_message',
});
export type DMOperationType = $Values<typeof dmOperationTypes>;
@@ -108,11 +109,32 @@
action: t.enums.of(['add_reaction', 'remove_reaction']),
});
+export type DMSendEditMessageOperation = {
+ +type: 'send_edit_message',
+ +threadID: string,
+ +creatorID: string,
+ +time: number,
+ +messageID: string,
+ +targetMessageID: string,
+ +text: string,
+};
+export const dmSendEditMessageOperation: TInterface<DMSendEditMessageOperation> =
+ tShape<DMSendEditMessageOperation>({
+ type: tString(dmOperationTypes.SEND_EDIT_MESSAGE),
+ threadID: t.String,
+ creatorID: tUserID,
+ time: t.Number,
+ messageID: t.String,
+ targetMessageID: t.String,
+ text: t.String,
+ });
+
export type DMOperation =
| DMCreateThreadOperation
| DMCreateSidebarOperation
| DMSendTextMessageOperation
- | DMSendReactionMessageOperation;
+ | DMSendReactionMessageOperation
+ | DMSendEditMessageOperation;
export type DMOperationResult = {
rawMessageInfos: Array<RawMessageInfo>,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 4:53 PM (19 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571630
Default Alt Text
D12807.id42554.diff (2 KB)
Attached To
Mode
D12807: [lib] DMOperationSpec for edit operation
Attached
Detach File
Event Timeline
Log In to Comment