From f3a05929d984af6aa9d3b08a82d6af211eb71ee0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 5 Aug 2021 11:01:40 +0200 Subject: [PATCH] Allow members-restricted posts to be viewable by instance moderators But add a warning message on top of the post Signed-off-by: Thomas Citharel --- js/src/i18n/en_US.json | 7 +++- js/src/i18n/fr_FR.json | 7 +++- js/src/mixins/group.ts | 8 +++++ js/src/views/Group/Group.vue | 22 +----------- js/src/views/Posts/List.vue | 2 +- js/src/views/Posts/Post.vue | 36 +++++++++++++++++-- .../components/Group/GroupSection.spec.ts | 2 +- .../__snapshots__/GroupSection.spec.ts.snap | 4 +-- lib/graphql/resolvers/post.ex | 6 ++-- 9 files changed, 62 insertions(+), 32 deletions(-) diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index 234ea1da..55450901 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -1067,5 +1067,10 @@ "View less": "View less", "View more": "View more", "Breadcrumbs": "Breadcrumbs", - "Other actions": "Other actions" + "Other actions": "Other actions", + "Only group moderators can create, edit and delete events.": "Only group moderators can create, edit and delete events.", + "+ Create a post": "+ Create a post", + "Edited {relative_time} ago": "Edited {relative_time} ago", + "Members-only post": "Members-only post", + "This post is accessible only for members. You have access to it for moderation purposes only because you are an instance moderator.": "This post is accessible only for members. You have access to it for moderation purposes only because you are an instance moderator." } diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index 9410d743..cc125b8f 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -1158,5 +1158,10 @@ "View less": "Voir moins", "View more": "Voir plus", "Breadcrumbs": "Fil d'Ariane", - "Other actions": "Autres actions" + "Other actions": "Autres actions", + "Only group moderators can create, edit and delete events.": "Seule⋅s les modérateur⋅ices de groupe peuvent créer, éditer et supprimer des événements.", + "+ Create a post": "+ Créer un billet", + "Edited {relative_time} ago": "Édité il y a {relative_time}", + "Members-only post": "Billet reservé aux membres", + "This post is accessible only for members. You have access to it for moderation purposes only because you are an instance moderator.": "Ce billet est accessible uniquement aux membres. Vous y avez accès à des fins de modération car vous êtes modérateur⋅ice de l'instance." } diff --git a/js/src/mixins/group.ts b/js/src/mixins/group.ts index b287fbd8..9b320e6a 100644 --- a/js/src/mixins/group.ts +++ b/js/src/mixins/group.ts @@ -84,6 +84,14 @@ export default class GroupMixin extends Vue { ]); } + get isCurrentActorAGroupMember(): boolean { + return this.hasCurrentActorThisRole([ + MemberRole.MODERATOR, + MemberRole.ADMINISTRATOR, + MemberRole.MEMBER, + ]); + } + hasCurrentActorThisRole(givenRole: string | string[]): boolean { const roles = Array.isArray(givenRole) ? givenRole : [givenRole]; return ( diff --git a/js/src/views/Group/Group.vue b/js/src/views/Group/Group.vue index 34d06824..f659406f 100644 --- a/js/src/views/Group/Group.vue +++ b/js/src/views/Group/Group.vue @@ -404,7 +404,7 @@ params: { preferredUsername: usernameWithDomain(group) }, }" class="button is-primary" - >{{ $t("+ Post a public message") }}{{ $t("+ Create a post") }} @@ -800,31 +800,11 @@ export default class Group extends mixins(GroupMixin) { return undefined; } - get groupMemberships(): (string | undefined)[] { - return this.person?.memberships?.elements - .filter( - (membership: IMember) => - ![ - MemberRole.REJECTED, - MemberRole.NOT_APPROVED, - MemberRole.INVITED, - ].includes(membership.role) - ) - .map(({ parent: { id } }) => id); - } - @Watch("isCurrentActorAGroupMember") refetchGroupData(): void { this.$apollo.queries.group.refetch(); } - get isCurrentActorAGroupMember(): boolean { - return ( - this.groupMemberships !== undefined && - this.groupMemberships.includes(this.group.id) - ); - } - get isCurrentActorARejectedGroupMember(): boolean { return ( this.person && diff --git a/js/src/views/Posts/List.vue b/js/src/views/Posts/List.vue index 1fb176f3..85288374 100644 --- a/js/src/views/Posts/List.vue +++ b/js/src/views/Posts/List.vue @@ -45,7 +45,7 @@ params: { preferredUsername: usernameWithDomain(group) }, }" class="button is-primary" - >{{ $t("+ Post a public message") }}{{ $t("+ Create a post") }}
diff --git a/js/src/views/Posts/Post.vue b/js/src/views/Posts/Post.vue index 221f87e1..671475fc 100644 --- a/js/src/views/Posts/Post.vue +++ b/js/src/views/Posts/Post.vue @@ -1,5 +1,5 @@