From af19e31178a339f47097c77869a9127d6e45ade4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Apr 2023 14:32:30 +0200 Subject: [PATCH 1/2] fix(backend): posts in groups cannot be pinned --- backend/src/schema/resolvers/posts.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index d806f3803..063b2210d 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -310,6 +310,7 @@ export default { ` MATCH (user:User {id: $userId}) WHERE user.role = 'admin' MATCH (post:Post {id: $params.id}) + WHERE NOT((post)-[:IN]->(:Group)) MERGE (user)-[pinned:PINNED {createdAt: toString(datetime())}]->(post) SET post.pinned = true RETURN post, pinned.createdAt as pinnedAt @@ -322,10 +323,12 @@ export default { })) }) const [transactionResult] = await writeTxResultPromise - const { pinnedPost, pinnedAt } = transactionResult - pinnedPostWithNestedAttributes = { - ...pinnedPost, - pinnedAt, + if (transactionResult) { + const { pinnedPost, pinnedAt } = transactionResult + pinnedPostWithNestedAttributes = { + ...pinnedPost, + pinnedAt, + } } } finally { session.close() From b672b62e0df42804d6c72bd363eb52800590132a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Apr 2023 14:33:51 +0200 Subject: [PATCH 2/2] no pin post button for posts in group --- webapp/components/ContentMenu/ContentMenu.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/components/ContentMenu/ContentMenu.vue b/webapp/components/ContentMenu/ContentMenu.vue index 60bcccf43..d723a9667 100644 --- a/webapp/components/ContentMenu/ContentMenu.vue +++ b/webapp/components/ContentMenu/ContentMenu.vue @@ -80,7 +80,7 @@ export default { }) } - if (this.isAdmin) { + if (this.isAdmin && !this.resource.group) { if (!this.resource.pinnedBy) { routes.push({ label: this.$t(`post.menu.pin`),