Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33049673
D13023.1768422744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D13023.1768422744.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
Wed, Jan 14, 8:32 PM (3 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5933830
Default Alt Text
D13023.1768422744.diff (2 KB)
Attached To
Mode
D13023: Implement notificationsCreationData for chante-thread-settings-spec
Attached
Detach File
Event Timeline
Log In to Comment