Website request - Let forum moderators merge duplicate posts

Open
#22,347 5 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@smallbrownbike is already working on this.

Since Nov 13, 2026.

Assessment

This issue has not been assessed yet.

Description

website

What do you need?

A "Merge into another post…" action in the forum's Moderate menu. Moderators use it when two posts ask the same question. The duplicate post (the source) merges into the other post (the target):

  • All comments on the source move to the target.
  • The source's text becomes a comment on the target, under its original author.
  • People who follow the source now follow the target.
  • Links to the source open the target.

Today, a moderator can only archive or delete a duplicate. Both hide the comments on it, and the old link stops working.

Draft content

Not applicable. This is a feature, not a content change. The proposed design is below.

Proposed approach

The merge must happen on the server, in one transaction. A merge in the browser (PUT /api/replies/:id for each comment) is not safe:

  • If it fails partway, the comments are split across the two posts.
  • The source text gets the moderator as its author.
  • Followers, upvotes, counts, and the search index do not move.
  • The server can refuse a reply update from a community moderator.
Behavior

Rules. The server refuses the merge if one of these is false:

  • The caller is a forum moderator (see open question 1).
  • Both posts are published forum posts (they have a forumTopic and a publishedAt).
  • The source and the target are different posts.
  • The target is not already merged into another post.

What happens:

  • Comments: all comments on the source move to the target. This includes unpublished comments. Each comment keeps its author, date, votes, and edits. The thread sorts comments by date, so the moved comments mix with the target's comments in date order.
  • Source text: becomes a new comment on the target. The author is the source author, and the date is the source's publish date. The comment starts with **Merged from: <source subject>**, so the subject is not lost.
  • Target: keeps its subject, topic, tags, pin, lock, and solution. A comment that was the solution on the source becomes a normal comment.
  • Followers: every profile that follows the source also follows the target.
  • Upvotes: the target gets the upvotes from both posts. A profile that upvoted both counts once.
  • Source: set to archived: true and mergedInto: <target>. The record stays in the database for audit.
  • Earlier merges: a post whose mergedInto is the source now points to the target, so a link never needs two redirects.
  • No side effects: no new-comment emails, notifications, or Slack alerts. No points or reputation changes. Jev does not tag the target again, and PostHog AI does not reply.
squeak-strapi
  1. Schema: add mergedInto to question (many-to-one relation to api::question.question). For audit, you can also add mergedAt (datetime) and mergedBy (relation to profile).
  2. Route: POST /api/questions/:id/merge with the body { "into": <targetId> }. Use the same policy as the other moderator actions (pin, lock, move to topic).
  3. Service: do all steps in one strapi.db.transaction:
    1. Load both posts and check the rules.
    2. Create the "Merged from" comment on the target.
    3. Move every reply from the source to the target.
    4. Add the target to questionSubscriptions for each profile that follows the source.
    5. Join the upvotes.
    6. Calculate the target's numReplies, activeAt, lastReplyAt, lastReplyBy, participants, and Active and Popular scores again. Use the code that runs after a new reply, so the values stay the same as for a normal reply.
    7. Archive the source, set mergedInto, and change earlier mergedInto values that point to the source.
  4. Hooks: write the replies so the reply lifecycle hooks do not send emails or give points. Either use strapi.db.query, or pass a flag that the hooks check.
  5. Search: after the commit, remove the source from the Algolia index and update the target.
  6. Response: return the target's id and permalink.
  7. Docs: add the route to docs/forum-api.md.
  8. Tests:
    • a merge that succeeds
    • a caller who is not a moderator
    • the same post as source and target
    • a draft
    • a target that is already merged
    • a rollback when a step fails
posthog.com

This is a small change, and it reuses parts that already exist. It needs the Strapi route first.

File Change
src/lib/strapi.ts Add mergedInto?: { data: StrapiRecord<QuestionData> | null } to QuestionData
src/components/Squeak/hooks/useQuestion.tsx Populate mergedInto: { fields: ['permalink', 'subject'] }
src/components/Forum/hooks.ts Add mergePost(id, into) to useForumPost, next to updatePost
src/components/Forum/Thread.tsx Add the Moderate menu item, a MergeDialog, and the redirect
src/components/Forum/README.md Add merge to the roles table and the Thread.tsx row

MergeDialog uses the same parts as MoveDialog (Modal, OSButton):

  • A search field finds the target by subject. It uses useForumPostSearch, which the # suggestions already use. The list does not show the current post.
  • After the moderator selects a target, the dialog shows: "N comments and the text of this post move to . This post is archived, and its link opens the other post. You cannot undo this."
  • Buttons: Cancel and Merge posts. When the merge succeeds, a "Merged" toast shows and the window opens /forum/p/<target permalink>.

Redirect: when post.mergedInto has data, Thread goes to the target (with replace) and shows the toast "This post was merged into ". This works for old links, emails, search results, and hover cards.

Feeds need no change, because useQuestions already hides archived posts.

The PR needs before and after screenshots of the menu and the dialog: a narrow and a wide window, in light and dark mode.

Out of scope
  • Undo (unmerge). The moved comments mix with the target's comments, so an undo is difficult. See open question 2.
  • Merging more than two posts in one step. To merge more, do it again.
  • Comment threads on docs and blog pages (questions without a forumTopic).
Open questions
  1. Who can merge? Community moderators (isForumModerator), as for move and archive? Or only staff (isModerator)? I recommend community moderators, because the source record stays, so a moderator can repair a bad merge by hand.
  2. Should each moved comment record mergedFrom? It costs little now, and it would make an undo possible later.
  3. Should the source author get an email that says their post was merged, with a link to the target?

References & examples

  • Current moderator actions: the Moderate menu in src/components/Forum/Thread.tsx (pin, lock, move to topic, edit tags, archive).
  • A similar pattern: "move to another tag" when you delete a tag, in src/components/Forum/TopicTags.tsx.
  • Other forums: Discourse "Move to existing topic", and GitHub "Close as duplicate".

Deadline

No deadline.

Dominant language
TypeScript
Stars
1.2k
Forks
952
Avg merge
1d 17h
Merged PRs (30d)
747

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PostHog/posthog.com

All issues in PostHog/posthog.com

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.