Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32258059
D8502.1765243149.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D8502.1765243149.diff
View Options
diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js
--- a/keyserver/src/updaters/thread-updaters.js
+++ b/keyserver/src/updaters/thread-updaters.js
@@ -155,6 +155,7 @@
time: Date.now(),
userIDs: memberIDs,
newRole: request.role,
+ roleName: threadInfo.roles[request.role].name,
};
const newMessageInfos = await createMessages(viewer, [messageData]);
diff --git a/lib/shared/messages/change-role-message-spec.js b/lib/shared/messages/change-role-message-spec.js
--- a/lib/shared/messages/change-role-message-spec.js
+++ b/lib/shared/messages/change-role-message-spec.js
@@ -9,6 +9,7 @@
type RobotextParams,
} from './message-spec.js';
import { joinResult } from './utils.js';
+import type { PlatformDetails } from '../../types/device-types.js';
import { messageTypes } from '../../types/message-types-enum.js';
import type {
MessageInfo,
@@ -20,6 +21,7 @@
type RawChangeRoleMessageInfo,
rawChangeRoleMessageInfoValidator,
} from '../../types/messages/change-role.js';
+import type { RawUnsupportedMessageInfo } from '../../types/messages/unsupported';
import type { NotifTexts } from '../../types/notif-types.js';
import type { ThreadInfo } from '../../types/thread-types.js';
import type { RelativeUserInfo } from '../../types/user-types.js';
@@ -30,6 +32,7 @@
} from '../../utils/entity-text.js';
import { values } from '../../utils/objects.js';
import { notifRobotextForMessageInfo } from '../notif-utils.js';
+import { NEXT_CODE_VERSION, hasMinCodeVersion } from '../version-utils.js';
export const changeRoleMessageSpec: MessageSpec<
ChangeRoleMessageData,
@@ -42,6 +45,7 @@
return JSON.stringify({
userIDs: data.userIDs,
newRole: data.newRole,
+ roleName: data.roleName,
});
},
@@ -59,6 +63,7 @@
creatorID: row.creatorID.toString(),
userIDs: content.userIDs,
newRole: content.newRole,
+ roleName: content.roleName,
};
},
@@ -79,6 +84,7 @@
creatorID: clientDBMessageInfo.user,
userIDs: content.userIDs,
newRole: content.newRole,
+ roleName: content.roleName,
};
return rawChangeRoleMessageInfo;
},
@@ -97,6 +103,7 @@
time: rawMessageInfo.time,
members,
newRole: rawMessageInfo.newRole,
+ roleName: rawMessageInfo.roleName,
};
},
@@ -122,7 +129,15 @@
const { threadInfo } = params;
invariant(threadInfo, 'ThreadInfo should be set for CHANGE_ROLE message');
- const roleName = threadInfo.roles[messageInfo.newRole].name;
+
+ const threadRoleName = threadInfo.roles[messageInfo.newRole]?.name || null;
+ const messageInfoRoleName = messageInfo.roleName;
+
+ const roleName = threadRoleName || messageInfoRoleName;
+ invariant(
+ roleName,
+ 'roleName should either be derived from threadInfo or messageInfo',
+ );
return ET`${creator} assigned ${affectedUsers} the \"${roleName}\" role`;
},
@@ -162,6 +177,34 @@
};
},
+ shimUnsupportedMessageInfo(
+ rawMessageInfo: RawChangeRoleMessageInfo,
+ platformDetails: ?PlatformDetails,
+ ): RawChangeRoleMessageInfo | RawUnsupportedMessageInfo {
+ if (hasMinCodeVersion(platformDetails, { native: NEXT_CODE_VERSION })) {
+ return rawMessageInfo;
+ }
+
+ const { id } = rawMessageInfo;
+ invariant(id !== null && id !== undefined, 'id should be set on server');
+
+ return {
+ type: messageTypes.UNSUPPORTED,
+ id,
+ threadID: rawMessageInfo.threadID,
+ creatorID: rawMessageInfo.creatorID,
+ time: rawMessageInfo.time,
+ robotext: 'changed the role of some members',
+ unsupportedMessageInfo: rawMessageInfo,
+ };
+ },
+
+ unshimMessageInfo(
+ unwrapped: RawChangeRoleMessageInfo,
+ ): RawChangeRoleMessageInfo {
+ return unwrapped;
+ },
+
notificationCollapseKey(rawMessageInfo: RawChangeRoleMessageInfo): string {
return joinResult(
rawMessageInfo.type,
diff --git a/lib/types/messages/change-role.js b/lib/types/messages/change-role.js
--- a/lib/types/messages/change-role.js
+++ b/lib/types/messages/change-role.js
@@ -7,17 +7,18 @@
import type { RelativeUserInfo } from '../user-types.js';
export type ChangeRoleMessageData = {
- type: 6,
- threadID: string,
- creatorID: string,
- time: number,
- userIDs: string[],
- newRole: string,
+ +type: 6,
+ +threadID: string,
+ +creatorID: string,
+ +time: number,
+ +userIDs: string[],
+ +newRole: string,
+ +roleName?: string, // Older clients will not have this field
};
export type RawChangeRoleMessageInfo = {
...ChangeRoleMessageData,
- id: string,
+ +id: string,
};
export const rawChangeRoleMessageInfoValidator: TInterface<RawChangeRoleMessageInfo> =
@@ -32,11 +33,12 @@
});
export type ChangeRoleMessageInfo = {
- type: 6,
- id: string,
- threadID: string,
- creator: RelativeUserInfo,
- time: number,
- members: RelativeUserInfo[],
- newRole: string,
+ +type: 6,
+ +id: string,
+ +threadID: string,
+ +creator: RelativeUserInfo,
+ +time: number,
+ +members: RelativeUserInfo[],
+ +newRole: string,
+ +roleName?: string, // Older clients will not have this field
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 9, 1:19 AM (7 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5851904
Default Alt Text
D8502.1765243149.diff (5 KB)
Attached To
Mode
D8502: [keyserver/lib] Update the change_role message spec to include a role name field in the DB
Attached
Detach File
Event Timeline
Log In to Comment