Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3303033
D13023.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
D13023.diff
View Options
diff --git a/lib/shared/dm-ops/change-thread-settings-spec.js b/lib/shared/dm-ops/change-thread-settings-spec.js
--- a/lib/shared/dm-ops/change-thread-settings-spec.js
+++ b/lib/shared/dm-ops/change-thread-settings-spec.js
@@ -15,11 +15,15 @@
import type { DMChangeThreadSettingsOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import type { RawMessageInfo } from '../../types/message-types.js';
+import type { AddMembersMessageData } from '../../types/messages/add-members.js';
+import type { ChangeSettingsMessageData } from '../../types/messages/change-settings.js';
import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
+import type { NotificationsCreationData } from '../../types/notif-types.js';
import type { LegacyRawThreadInfo } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type { ClientUpdateInfo } from '../../types/update-types.js';
import { values } from '../../utils/objects.js';
+import { firstLine } from '../../utils/string-utils.js';
function createAddMembersOperation(
dmOperation: DMChangeThreadSettingsOperation,
@@ -166,6 +170,66 @@
utilities,
);
},
+ notificationsCreationData(
+ dmOp: DMChangeThreadSettingsOperation,
+ ): NotificationsCreationData {
+ const {
+ existingThreadDetails: { threadID },
+ editorID: creatorID,
+ time,
+ changes,
+ } = dmOp;
+ const messageDatas: Array<
+ ChangeSettingsMessageData | AddMembersMessageData,
+ > = [];
+
+ const normalizedChanges: {
+ [string]: string,
+ } = {};
+
+ const { name, color, description, avatar, newMemberIDs } = changes;
+
+ if (name) {
+ normalizedChanges.name = firstLine(name);
+ }
+
+ if (color) {
+ normalizedChanges.color = color.toLowerCase();
+ }
+
+ if (description) {
+ normalizedChanges.description = description;
+ }
+
+ if (avatar) {
+ normalizedChanges.avatar = JSON.stringify(avatar);
+ }
+
+ for (const field in normalizedChanges) {
+ const value = normalizedChanges[field];
+ messageDatas.push({
+ type: messageTypes.CHANGE_SETTINGS,
+ threadID,
+ creatorID,
+ time,
+ value,
+ field,
+ });
+ }
+
+ if (newMemberIDs && newMemberIDs.length > 0) {
+ messageDatas.push({
+ type: messageTypes.ADD_MEMBERS,
+ threadID,
+ creatorID,
+ time,
+ addedUserIDs: [...newMemberIDs],
+ });
+ }
+ return {
+ messageDatas,
+ };
+ },
});
export { changeThreadSettingsSpec };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 9:53 AM (20 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2537660
Default Alt Text
D13023.diff (2 KB)
Attached To
Mode
D13023: Implement notificationsCreationData for chante-thread-settings-spec
Attached
Detach File
Event Timeline
Log In to Comment