groupPinned field on post

This commit is contained in:
Ulf Gebhardt 2026-01-15 14:12:28 +01:00
parent 3c3adb4381
commit 96deaf668b
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 17 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import { filterPostsOfMyGroups } from './helpers/filterPostsOfMyGroups'
import Resolver from './helpers/Resolver'
import { images } from './images/images'
import { createOrUpdateLocations } from './users/location'
import { r } from '@faker-js/faker/dist/airline-CLphikKp'
const maintainPinnedPosts = (params) => {
const pinnedPostFilter = { pinned: true }
@ -647,6 +648,18 @@ export default {
'MATCH (this)<-[obs:OBSERVES]-(related:User {id: $cypherParams.currentUserId}) WHERE obs.active = true RETURN COUNT(related) >= 1',
},
}),
groupPinned: async (parent, _params, context, _resolveInfo) => {
return (
(
await context.database.query({
query: `
MATCH (:User)-[pinned:GROUP_PINNED]->(:Post {id: $parent.id})
RETURN pinned`,
variables: { parent },
})
).records.length === 1
)
},
relatedContributions: async (parent, _params, context, _resolveInfo) => {
if (typeof parent.relatedContributions !== 'undefined') return parent.relatedContributions
const { id } = parent

View File

@ -128,6 +128,7 @@ type Post {
deleted: Boolean
disabled: Boolean
pinned: Boolean
groupPinned: Boolean
createdAt: String
updatedAt: String
sortDate: String

View File

@ -205,10 +205,10 @@ export default {
)
},
isPinned() {
return this.post && this.post.pinned
return this.post && (this.post.pinned || this.post.groupPinned)
},
ribbonText() {
if (this.post.pinned) return this.$t('post.pinned')
if (this.post.pinned || this.post.groupPinned) return this.$t('post.pinned')
if (this.post.postType[0] === 'Event') return this.$t('post.event')
return this.$t('post.name')
},

View File

@ -27,6 +27,7 @@ export const post = gql`
}
pinnedAt
pinned
groupPinned
isObservedByMe
observingUsersCount
}