Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable mention_all permission til users upgraded #4423

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
{roles}
label={$_("permissions.replyInThread")}
bind:rolePermission={permissions.replyInThread} />
<SelectPermissionRole
<!-- <SelectPermissionRole
{roles}
label={$_("permissions.mentionAllMembers", { values: { mention: "@everyone" } })}
bind:rolePermission={permissions.mentionAllMembers} />
bind:rolePermission={permissions.mentionAllMembers} /> -->
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions frontend/openchat-agent/src/services/common/chatMappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {
ApiTotalPollVotes,
ApiPollConfig,
ApiGroupPermissions,
ApiGroupPermissionsReduced,
ApiPermissionRole,
ApiGiphyContent,
ApiGiphyImageVariant,
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions frontend/openchat-agent/src/services/user/candid/idl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ import {
DeleteCommunityResponse,
ArchiveUnarchiveChatsResponse,
SetCommunityIndexesResponse,
GroupPermissionsReduced
} from "./types";
export {
_SERVICE as UserService,
Expand Down Expand Up @@ -272,6 +273,7 @@ export {
DeleteCommunityResponse as ApiDeleteCommunityResponse,
ArchiveUnarchiveChatsResponse as ApiArchiveUnarchiveChatsResponse,
SetCommunityIndexesResponse as ApiSetCommunityIndexesResponse,
GroupPermissionsReduced as ApiGroupPermissionsReduced,
};

export const idlFactory: IDL.InterfaceFactory;
17 changes: 16 additions & 1 deletion frontend/openchat-agent/src/services/user/candid/idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
17 changes: 16 additions & 1 deletion frontend/openchat-agent/src/services/user/candid/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions frontend/openchat-agent/src/services/user/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ import {
chatMetrics,
completedCryptoTransfer,
accessGate,
groupPermissions,
message,
messageContent,
groupPermissionsReduced,
} from "../common/chatMappers";
import { ensureReplicaIsUpToDate } from "../common/replicaUpToDateChecker";
import { ReplicaNotUpToDateError } from "../error";
Expand Down Expand Up @@ -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,
Expand Down
Loading