fix(chunter-trigger): seed default collaborators onto the target doc, not the ChatMessage#10973
Open
MichaelUray wants to merge 1 commit into
Open
fix(chunter-trigger): seed default collaborators onto the target doc, not the ChatMessage#10973MichaelUray wants to merge 1 commit into
MichaelUray wants to merge 1 commit into
Conversation
… 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>
|
Connected to Huly®: UBERF-16656 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
OnChatMessageCreatedseeding default collaborators onto the newly createdChatMessageinstead of the message's target document.The trigger already resolves
targetDoc, but the seed path passedtx.objectId / tx.objectClass / tx.objectSpaceintogetAddCollaboratTxes(). For aTxCreateDoc<ChatMessage>, those values describe the message itself, not the document the message is attached to.Fix
Pass
targetDoc._id / targetDoc._class / targetDoc.spacewhen 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.tsforserver-plugins/chunter-resources.The test keeps
getAddCollaboratTxes()real and stubs only the collaborator source helpers, so it asserts the actualattachedTo,attachedToClass, andobjectSpacewiring.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 inserver-plugins/notification-resources. I left that out of scope to keep this PR focused on the Chunter trigger path.