diff --git a/frontend/app/src/components/home/GroupPermissionsEditor.svelte b/frontend/app/src/components/home/GroupPermissionsEditor.svelte index 5a36277fd5..a7b18b44bc 100644 --- a/frontend/app/src/components/home/GroupPermissionsEditor.svelte +++ b/frontend/app/src/components/home/GroupPermissionsEditor.svelte @@ -51,7 +51,7 @@ {roles} label={$_("permissions.replyInThread")} bind:rolePermission={permissions.replyInThread} /> - + bind:rolePermission={permissions.mentionAllMembers} /> --> diff --git a/frontend/app/src/components/home/GroupPermissionsViewer.svelte b/frontend/app/src/components/home/GroupPermissionsViewer.svelte index 1f4a4db8ac..26df44699a 100644 --- a/frontend/app/src/components/home/GroupPermissionsViewer.svelte +++ b/frontend/app/src/components/home/GroupPermissionsViewer.svelte @@ -20,7 +20,7 @@ $: partitioned = partitionPermissions(permissions); function filterPermissions([key, _]: PermissionsEntry): boolean { - if (isPublic && key === "inviteUsers") { + if ((isPublic && key === "inviteUsers") || key === "mentionAllMembers") { return false; } return true; diff --git a/frontend/openchat-agent/src/services/common/chatMappers.ts b/frontend/openchat-agent/src/services/common/chatMappers.ts index e5924e2373..2b01e9b844 100644 --- a/frontend/openchat-agent/src/services/common/chatMappers.ts +++ b/frontend/openchat-agent/src/services/common/chatMappers.ts @@ -30,6 +30,7 @@ import type { ApiTotalPollVotes, ApiPollConfig, ApiGroupPermissions, + ApiGroupPermissionsReduced, ApiPermissionRole, ApiGiphyContent, ApiGiphyImageVariant, @@ -837,6 +838,22 @@ export function groupPermissions(candid: ApiGroupPermissions): ChatPermissions { }; } +export function groupPermissionsReduced(candid: ApiGroupPermissionsReduced): ChatPermissions { + return { + changeRoles: permissionRole(candid.change_roles), + updateGroup: permissionRole(candid.update_group), + inviteUsers: permissionRole(candid.invite_users), + removeMembers: permissionRole(candid.remove_members), + deleteMessages: permissionRole(candid.delete_messages), + pinMessages: permissionRole(candid.pin_messages), + createPolls: permissionRole(candid.create_polls), + sendMessages: permissionRole(candid.send_messages), + reactToMessages: permissionRole(candid.react_to_messages), + replyInThread: permissionRole(candid.reply_in_thread), + mentionAllMembers: "admin", + }; +} + export function communityPermissions(candid: ApiCommunityPermissions): CommunityPermissions { return { changeRoles: communityPermissionRole(candid.change_roles), diff --git a/frontend/openchat-agent/src/services/user/candid/idl.d.ts b/frontend/openchat-agent/src/services/user/candid/idl.d.ts index 8ac140d45c..8440a50896 100644 --- a/frontend/openchat-agent/src/services/user/candid/idl.d.ts +++ b/frontend/openchat-agent/src/services/user/candid/idl.d.ts @@ -135,6 +135,7 @@ import { DeleteCommunityResponse, ArchiveUnarchiveChatsResponse, SetCommunityIndexesResponse, + GroupPermissionsReduced } from "./types"; export { _SERVICE as UserService, @@ -272,6 +273,7 @@ export { DeleteCommunityResponse as ApiDeleteCommunityResponse, ArchiveUnarchiveChatsResponse as ApiArchiveUnarchiveChatsResponse, SetCommunityIndexesResponse as ApiSetCommunityIndexesResponse, + GroupPermissionsReduced as ApiGroupPermissionsReduced, }; export const idlFactory: IDL.InterfaceFactory; diff --git a/frontend/openchat-agent/src/services/user/candid/idl.js b/frontend/openchat-agent/src/services/user/candid/idl.js index f964f5228d..5ba7d6c797 100644 --- a/frontend/openchat-agent/src/services/user/candid/idl.js +++ b/frontend/openchat-agent/src/services/user/candid/idl.js @@ -161,6 +161,21 @@ export const idlFactory = ({ IDL }) => { 'reply_in_thread' : PermissionRole, 'react_to_messages' : PermissionRole, }); + const GroupPermissionsReduced = IDL.Record({ + 'block_users' : PermissionRole, + 'change_permissions' : PermissionRole, + 'delete_messages' : PermissionRole, + 'send_messages' : PermissionRole, + 'remove_members' : PermissionRole, + 'update_group' : PermissionRole, + 'invite_users' : PermissionRole, + 'change_roles' : PermissionRole, + 'add_members' : PermissionRole, + 'create_polls' : PermissionRole, + 'pin_messages' : PermissionRole, + 'reply_in_thread' : PermissionRole, + 'react_to_messages' : PermissionRole, + }); const CreateGroupArgs = IDL.Record({ 'is_public' : IDL.Bool, 'permissions' : IDL.Opt(GroupPermissions), @@ -869,7 +884,7 @@ export const idlFactory = ({ IDL }) => { }); const GroupChatSummary = IDL.Record({ 'is_public' : IDL.Bool, - 'permissions' : GroupPermissions, + 'permissions' : GroupPermissionsReduced, 'metrics' : ChatMetrics, 'subtype' : IDL.Opt(GroupSubtype), 'date_last_pinned' : IDL.Opt(TimestampMillis), diff --git a/frontend/openchat-agent/src/services/user/candid/types.d.ts b/frontend/openchat-agent/src/services/user/candid/types.d.ts index b3dae93880..c617c8e789 100644 --- a/frontend/openchat-agent/src/services/user/candid/types.d.ts +++ b/frontend/openchat-agent/src/services/user/candid/types.d.ts @@ -755,7 +755,7 @@ export interface GroupChatCreated { } export interface GroupChatSummary { 'is_public' : boolean, - 'permissions' : GroupPermissions, + 'permissions' : GroupPermissionsReduced, 'metrics' : ChatMetrics, 'subtype' : [] | [GroupSubtype], 'date_last_pinned' : [] | [TimestampMillis], @@ -860,6 +860,21 @@ export interface GroupPermissions { 'reply_in_thread' : PermissionRole, 'react_to_messages' : PermissionRole, } +export interface GroupPermissionsReduced { + 'block_users' : PermissionRole, + 'change_permissions' : PermissionRole, + 'delete_messages' : PermissionRole, + 'send_messages' : PermissionRole, + 'remove_members' : PermissionRole, + 'update_group' : PermissionRole, + 'invite_users' : PermissionRole, + 'change_roles' : PermissionRole, + 'add_members' : PermissionRole, + 'create_polls' : PermissionRole, + 'pin_messages' : PermissionRole, + 'reply_in_thread' : PermissionRole, + 'react_to_messages' : PermissionRole, +} export interface GroupReactionAddedNotification { 'added_by_name' : string, 'group_avatar_id' : [] | [bigint], diff --git a/frontend/openchat-agent/src/services/user/mappers.ts b/frontend/openchat-agent/src/services/user/mappers.ts index 45dd348fc2..3ca4fa1adf 100644 --- a/frontend/openchat-agent/src/services/user/mappers.ts +++ b/frontend/openchat-agent/src/services/user/mappers.ts @@ -126,9 +126,9 @@ import { chatMetrics, completedCryptoTransfer, accessGate, - groupPermissions, message, messageContent, + groupPermissionsReduced, } from "../common/chatMappers"; import { ensureReplicaIsUpToDate } from "../common/replicaUpToDateChecker"; import { ReplicaNotUpToDateError } from "../error"; @@ -774,7 +774,7 @@ function groupChatSummary(candid: ApiGroupChatSummary): GroupChatSummary { canisterId: candid.chat_id.toString(), })), memberCount: candid.participant_count, - permissions: groupPermissions(candid.permissions), + permissions: groupPermissionsReduced(candid.permissions), metrics: chatMetrics(candid.metrics), subtype: optional(candid.subtype, apiGroupSubtype), previewed: false,