Keep agent assigned on team change if they belong to the new team#297
Open
mageaustralia wants to merge 1 commit intoabhinavxd:mainfrom
Open
Keep agent assigned on team change if they belong to the new team#297mageaustralia wants to merge 1 commit intoabhinavxd:mainfrom
mageaustralia wants to merge 1 commit intoabhinavxd:mainfrom
Conversation
Reassigning a conversation to a different team currently always clears the user assignee. That's frustrating when an agent legitimately sits on both teams (common with shared inboxes / multi-team agents) — they have to be re-picked manually after every team move. Adds a UserBelongsToTeam check before unassigning. The helper already exists on the team store, so this is a small surgical change in UpdateConversationTeamAssignee. Also fixes the teamStore interface declaration whose param order (`userID, teamID`) didn't match the implementation (`teamID, userID`) — the SQL binds `team_id = $1 AND user_id = $2`, so the impl was correct and the interface was just mislabeled. With the two out of sync, an honest call against the interface produced silently-wrong results.
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.
What this changes
Reassigning a conversation to a different team currently always clears the assigned user. That's annoying when an agent legitimately sits on both teams (common with shared inboxes / multi-team agents) — they have to be re-picked manually after every team move.
This PR adds a
UserBelongsToTeamcheck before unassigning. If the agent belongs to the new team they stay, otherwise the existing unassign behaviour kicks in. The membership helper already exists on the team store, so this is a small surgical change inUpdateConversationTeamAssignee.Drive-by fix on the way
The
teamStoreinterface declaredUserBelongsToTeam(userID, teamID)but the implementation isUserBelongsToTeam(teamID, userID)and the SQL bindsteam_id = $1 AND user_id = $2. Impl + SQL agree; the interface label was reversed. With the two out of sync, an honest caller passing args in the order the interface advertises would silently get wrong results.I caught this by writing the call against the (misleading) interface, then having the change reviewed before opening — landed on fixing the interface to match the impl rather than papering over the call site. Updated the interface declaration so the next person isn't trapped.
Why no test
There are currently no
_test.gofiles underinternal/conversation/orinternal/team/, so adding one would require introducing test scaffolding (mockteamStore, etc.) for what's effectively a 3-line behaviour change. Happy to add a focused test if you'd prefer — just say the word.Test plan
assigned_user_changeactivity emitted