feat: close rooms in delete queue and sector endpoints#929
Open
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
Open
feat: close rooms in delete queue and sector endpoints#929MarcusviniciusLsantos wants to merge 5 commits intomainfrom
MarcusviniciusLsantos wants to merge 5 commits intomainfrom
Conversation
… active and waiting rooms
…arameters instead of request body for end_all_chats flag
kallilsouza
approved these changes
Mar 27, 2026
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.
Please check if the PR fulfills these requirements
What
Add support for the
end_all_chatsquery parameter on the DELETE endpoints for Sector (DELETE /api/v1/sector/{uuid}/) and Queue (DELETE /api/v1/queue/{uuid}/). When?end_all_chats=trueis provided, all active rooms (both ongoing with an assigned agent and waiting without an agent) are closed in batches before the sector/queue is deleted. The implementation reuses the existingBulkCloseService, preserving all business logic (tags, pins, InService status, CSAT, WebSocket notifications, metrics, and queue priority routing).Key behaviors:
false: existing behavior is unchanged.true, no active rooms: deletion proceeds normally.true, all rooms closed successfully: deletion proceeds.true, partial failure: logs a warning and proceeds with deletion.true, all rooms failed to close: returns 400 and aborts deletion.Files changed:
chats/apps/api/v1/sectors/viewsets.py— added_close_active_roomsand updatedperform_destroychats/apps/api/v1/queues/viewsets.py— added_close_active_roomsand updatedperform_destroychats/apps/sectors/tests/test_viewsets.py— addedSectorEndAllChatsTests(6 test cases)chats/apps/queues/tests/test_viewsets.py— addedQueueEndAllChatsTests(6 test cases)Why
When a sector or queue is deleted, any active rooms associated with it remain open in a broken state — they reference a queue/sector that no longer exists, which can lead to inconsistent data and a poor user experience. By allowing the caller to pass
end_all_chats=true, the API ensures all conversations are properly closed (with notifications, metrics, and CSAT flows triggered) before the resource is removed, maintaining data integrity and a clean shutdown of ongoing chats.