Merge pull request #6242 from Ocelot-Social-Community/group-posts-cannot-be-pinned

fix(backend): group posts cannot be pinned
This commit is contained in:
Moriz Wahl 2023-04-25 12:00:48 +02:00 committed by GitHub
commit 7b5a88187b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -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()

View File

@ -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`),