diff --git a/backend/src/graphql/resolvers/posts.ts b/backend/src/graphql/resolvers/posts.ts index 5563af70a..dc23334f4 100644 --- a/backend/src/graphql/resolvers/posts.ts +++ b/backend/src/graphql/resolvers/posts.ts @@ -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 diff --git a/backend/src/graphql/types/type/Post.gql b/backend/src/graphql/types/type/Post.gql index ac30b2be7..e48800d4a 100644 --- a/backend/src/graphql/types/type/Post.gql +++ b/backend/src/graphql/types/type/Post.gql @@ -128,6 +128,7 @@ type Post { deleted: Boolean disabled: Boolean pinned: Boolean + groupPinned: Boolean createdAt: String updatedAt: String sortDate: String diff --git a/webapp/components/PostTeaser/PostTeaser.vue b/webapp/components/PostTeaser/PostTeaser.vue index 5e1ec78d8..dc33206da 100644 --- a/webapp/components/PostTeaser/PostTeaser.vue +++ b/webapp/components/PostTeaser/PostTeaser.vue @@ -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') }, diff --git a/webapp/graphql/fragments/post.js b/webapp/graphql/fragments/post.js index b941931e9..94b4ea49f 100644 --- a/webapp/graphql/fragments/post.js +++ b/webapp/graphql/fragments/post.js @@ -27,6 +27,7 @@ export const post = gql` } pinnedAt pinned + groupPinned isObservedByMe observingUsersCount }