Skip to content

fix(chunter-trigger): seed default collaborators onto the target doc, not the ChatMessage#10973

Open
MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/chunter-seed-target
Open

fix(chunter-trigger): seed default collaborators onto the target doc, not the ChatMessage#10973
MichaelUray wants to merge 1 commit into
hcengineering:developfrom
MichaelUray:fix/chunter-seed-target

Conversation

@MichaelUray

@MichaelUray MichaelUray commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes OnChatMessageCreated seeding default collaborators onto the newly created ChatMessage instead of the message's target document.

The trigger already resolves targetDoc, but the seed path passed tx.objectId / tx.objectClass / tx.objectSpace into getAddCollaboratTxes(). For a TxCreateDoc<ChatMessage>, those values describe the message itself, not the document the message is attached to.

Fix

Pass targetDoc._id / targetDoc._class / targetDoc.space when seeding default collaborators.

This makes the first message seed the actual target document. Follow-up messages then see the existing collaborators and keep the expected notification/access behavior.

Tests

Added seedCollaborators.test.ts for server-plugins/chunter-resources.

The test keeps getAddCollaboratTxes() real and stubs only the collaborator source helpers, so it asserts the actual attachedTo, attachedToClass, and objectSpace wiring.

Red before the fix: collaborator attached to the message.
Green after the fix: collaborator attached to the target document.

Related follow-up

There is a similar-looking getAddCollaboratTxes(tx.objectId, ...) pattern in server-plugins/notification-resources. I left that out of scope to keep this PR focused on the Chunter trigger path.

… not the message

OnChatMessageCreated seeds a target doc's default collaborators when the doc
has none yet. The seed passed the ChatMessage create tx's own identity
(tx.objectId / tx.objectClass / tx.objectSpace) to getAddCollaboratTxes, so
the Collaborator records were attached to the ChatMessage instead of the
target doc. Two consequences:

- The target doc was never actually seeded: currentCollaborators stayed empty,
  so the defaults were lost and the seed re-evaluated on the next message.
- For provideSecurity classes the seed re-fired on every message and littered
  the message with Collaborator records.

Pass targetDoc._id / targetDoc._class / targetDoc.space instead.

This wrong-target is long-standing (pre-existing); hcengineering#9217 only mechanically
inherited the line and did not introduce the bug.

Adds a from-scratch jest harness (chunter-resources shipped no tests). It
drives ChunterTrigger with a TxCreateDoc<ChatMessage> on an empty target and
asserts the seeded Collaborator attaches to the target doc
(attachedTo / attachedToClass / objectSpace). getAddCollaboratTxes runs for
real — only getDocCollaborators and createCollaboratorNotifications are
stubbed — so the assertion exercises the actual wiring: red before the fix
(attachedTo = message id), green after.

A sibling of this bug lives in server-notification-resources collectionCollabDoc
(the createCollabDocInfo seeding path); left out of scope here.

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
@huly-github-staging

Copy link
Copy Markdown

Connected to Huly®: UBERF-16656

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant