Page MenuHomePhabricator

D13845.diff
No OneTemporary

D13845.diff

diff --git a/lib/shared/dm-ops/dm-op-specs.js b/lib/shared/dm-ops/dm-op-specs.js
--- a/lib/shared/dm-ops/dm-op-specs.js
+++ b/lib/shared/dm-ops/dm-op-specs.js
@@ -13,7 +13,6 @@
import { editEntrySpec } from './edit-entry-spec.js';
import { joinThreadSpec } from './join-thread-spec.js';
import { leaveThreadSpec } from './leave-thread-spec.js';
-import { removeMembersSpec } from './remove-members-spec.js';
import { sendEditMessageSpec } from './send-edit-message-spec.js';
import { sendMultimediaMessageSpec } from './send-multimedia-message-spec.js';
import { sendReactionMessageSpec } from './send-reaction-message-spec.js';
@@ -34,7 +33,6 @@
[dmOperationTypes.ADD_VIEWER_TO_THREAD_MEMBERS]: addViewerToThreadMembersSpec,
[dmOperationTypes.JOIN_THREAD]: joinThreadSpec,
[dmOperationTypes.LEAVE_THREAD]: leaveThreadSpec,
- [dmOperationTypes.REMOVE_MEMBERS]: removeMembersSpec,
[dmOperationTypes.CHANGE_THREAD_SETTINGS]: changeThreadSettingsSpec,
[dmOperationTypes.CHANGE_THREAD_SUBSCRIPTION]: changeThreadSubscriptionSpec,
[dmOperationTypes.CHANGE_THREAD_READ_STATUS]: changeThreadReadStatusSpec,
diff --git a/lib/shared/dm-ops/remove-members-spec.js b/lib/shared/dm-ops/remove-members-spec.js
deleted file mode 100644
--- a/lib/shared/dm-ops/remove-members-spec.js
+++ /dev/null
@@ -1,134 +0,0 @@
-// @flow
-
-import uuid from 'uuid';
-
-import type {
- DMOperationSpec,
- ProcessDMOperationUtilities,
-} from './dm-op-spec.js';
-import {
- type DMRemoveMembersOperation,
- dmRemoveMembersOperationValidator,
-} from '../../types/dm-ops.js';
-import { messageTypes } from '../../types/message-types-enum.js';
-import { threadTypes } from '../../types/thread-types-enum.js';
-import { updateTypes } from '../../types/update-types-enum.js';
-import type { ClientUpdateInfo } from '../../types/update-types.js';
-import { rawMessageInfoFromMessageData } from '../message-utils.js';
-
-function createMessageDataWithInfoFromDMOperation(
- dmOperation: DMRemoveMembersOperation,
-) {
- const { editorID, time, threadID, removedUserIDs, messageID } = dmOperation;
- const messageData = {
- type: messageTypes.REMOVE_MEMBERS,
- threadID,
- time,
- creatorID: editorID,
- removedUserIDs: [...removedUserIDs],
- };
- const rawMessageInfo = rawMessageInfoFromMessageData(messageData, messageID);
- return { messageData, rawMessageInfo };
-}
-
-const removeMembersSpec: DMOperationSpec<DMRemoveMembersOperation> =
- Object.freeze({
- processDMOperation: async (
- dmOperation: DMRemoveMembersOperation,
- utilities: ProcessDMOperationUtilities,
- ) => {
- const { time, threadID, removedUserIDs } = dmOperation;
- const { viewerID, threadInfos } = utilities;
- const threadInfo = threadInfos[threadID];
-
- const messageDataWithMessageInfos =
- createMessageDataWithInfoFromDMOperation(dmOperation);
- const { rawMessageInfo } = messageDataWithMessageInfos;
- const rawMessageInfos = [rawMessageInfo];
-
- const memberTimestamps = { ...threadInfo.timestamps.members };
- const removedUserIDsSet = new Set<string>();
- for (const userID of removedUserIDs) {
- if (!memberTimestamps[userID]) {
- memberTimestamps[userID] = {
- isMember: time,
- subscription: threadInfo.creationTime,
- };
- }
-
- if (memberTimestamps[userID].isMember > time) {
- continue;
- }
-
- memberTimestamps[userID] = {
- ...memberTimestamps[userID],
- isMember: time,
- };
-
- removedUserIDsSet.add(userID);
- }
-
- const viewerIsRemoved = removedUserIDsSet.has(viewerID);
- const updateInfos: Array<ClientUpdateInfo> = [];
- if (
- viewerIsRemoved &&
- (threadInfo.type !== threadTypes.THICK_SIDEBAR ||
- (threadInfo.parentThreadID &&
- !threadInfos[threadInfo.parentThreadID]))
- ) {
- updateInfos.push({
- type: updateTypes.DELETE_THREAD,
- id: uuid.v4(),
- time,
- threadID,
- });
- } else {
- const updatedThreadInfo = {
- ...threadInfo,
- members: threadInfo.members.filter(
- member => !removedUserIDsSet.has(member.id),
- ),
- timestamps: {
- ...threadInfo.timestamps,
- members: memberTimestamps,
- },
- };
- updateInfos.push({
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: updatedThreadInfo,
- });
- }
-
- const notificationsCreationData = {
- messageDatasWithMessageInfos: [messageDataWithMessageInfos],
- };
-
- return {
- rawMessageInfos,
- updateInfos,
- blobOps: [],
- notificationsCreationData,
- };
- },
- canBeProcessed: async (
- dmOperation: DMRemoveMembersOperation,
- utilities: ProcessDMOperationUtilities,
- ) => {
- if (utilities.threadInfos[dmOperation.threadID]) {
- return { isProcessingPossible: true };
- }
- return {
- isProcessingPossible: false,
- reason: {
- type: 'missing_thread',
- threadID: dmOperation.threadID,
- },
- };
- },
- supportsAutoRetry: true,
- operationValidator: dmRemoveMembersOperationValidator,
- });
-
-export { removeMembersSpec };
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
@@ -38,7 +38,6 @@
ADD_VIEWER_TO_THREAD_MEMBERS: 'add_viewer_to_thread_members',
JOIN_THREAD: 'join_thread',
LEAVE_THREAD: 'leave_thread',
- REMOVE_MEMBERS: 'remove_members',
CHANGE_THREAD_SETTINGS: 'change_thread_settings',
CHANGE_THREAD_SUBSCRIPTION: 'change_thread_subscription',
CHANGE_THREAD_READ_STATUS: 'change_thread_read_status',
@@ -294,24 +293,6 @@
threadID: t.String,
});
-export type DMRemoveMembersOperation = {
- +type: 'remove_members',
- +editorID: string,
- +time: number,
- +messageID: string,
- +threadID: string,
- +removedUserIDs: $ReadOnlyArray<string>,
-};
-export const dmRemoveMembersOperationValidator: TInterface<DMRemoveMembersOperation> =
- tShape<DMRemoveMembersOperation>({
- type: tString(dmOperationTypes.REMOVE_MEMBERS),
- editorID: tUserID,
- time: t.Number,
- messageID: t.String,
- threadID: t.String,
- removedUserIDs: t.list(tUserID),
- });
-
export type DMThreadSettingsChanges = {
+name?: string,
+description?: string,
@@ -483,7 +464,6 @@
| DMAddViewerToThreadMembersOperation
| DMJoinThreadOperation
| DMLeaveThreadOperation
- | DMRemoveMembersOperation
| DMChangeThreadSettingsOperation
| DMChangeThreadSubscriptionOperation
| DMChangeThreadReadStatusOperation
@@ -502,7 +482,6 @@
dmAddViewerToThreadMembersValidator,
dmJoinThreadOperationValidator,
dmLeaveThreadOperationValidator,
- dmRemoveMembersOperationValidator,
dmChangeThreadSettingsOperationValidator,
dmChangeThreadSubscriptionOperationValidator,
dmChangeThreadReadStatusOperationValidator,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 9:08 AM (18 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2560992
Default Alt Text
D13845.diff (6 KB)

Event Timeline