Skip to content
Snippets Groups Projects

feat: Restrict Comments on Posts in Groups

Merged Hannes Heine requested to merge comments-on-posts-in-groups into master

Created by: Mogge

:cake: Pullrequest

Ensure that no posts in groups can be commented by users that are not member of the group.

Issues

Todo

  • None

Merge request reports

Merged by avatar (Jul 7, 2025 3:30pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
250 250 })
251 251
252 const canCommentPost = rule({
253 cache: 'no_cache',
254 })(async (_parent, args, { user, driver }) => {
255 if (!(user && user.id)) return false
256 const { postId } = args
257 const userId = user.id
258 const session = driver.session()
259 const readTxPromise = session.readTransaction(async (transaction) => {
260 const transactionResponse = await transaction.run(
261 `
262 MATCH (post:Post { id: $postId })
263 OPTIONAL MATCH (post)-[:IN]->(group:Group)
264 OPTIONAL MATCH (user:User { id: $userId })-[membership:MEMBER_OF]->(group)
265 RETURN group AS group, membership AS membership
  • Created by: Tirokk

    Review: Approved

    Hey @Mogge Very nice that you did this !!! :heart_eyes:

    What I have found is:

    • with this in the webapp I can comment on a post of a public group, but get an error from the backend if I submit the comment

    In my eyes:

    • If commenting a post in a public group shall be possible …
      • we have to adjust the backend
    • If commenting a post in a public group shall not be possible …
      • we have to disable the commenting funktionallity on the post
      • and should display the reason why this is not possible
      • making a followup issue?
  • Merged by: Mogge at 2022-10-27 18:43:55 UTC

  • Please register or sign in to reply
    Loading