-
Notifications
You must be signed in to change notification settings - Fork 224
Handle user banned events in livestream controller #3777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle user banned events in livestream controller #3777
Conversation
WalkthroughAdds handling for UserBannedEvent and UserUnbannedEvent in LivestreamChannelController to refresh channel state from the datastore; updates demo UI to refresh the composer and disable sending for banned users; adds tests validating membership ban/unban state; updates CHANGELOG. No public API changes. Changes
Sequence Diagram(s)sequenceDiagram
participant EventBus
participant LivestreamChannelController as Controller
participant DataStore
participant DemoUI
EventBus->>Controller: UserBannedEvent / UserUnbannedEvent (for channel)
Controller->>DataStore: updateChannelFromDataStore()
DataStore-->>Controller: Channel + Membership (updated ban flag)
Controller-->>DemoUI: Channel state updated
DemoUI->>DemoUI: Refresh composer / disable or enable send
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Public Interface🚀 No changes affecting the public interface. |
SDK Size
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Sources/StreamChat/Controllers/ChannelController/LivestreamChannelController.swift (1)
917-919
: Narrow ban/unban handling to current user to avoid unnecessary refreshesRight now we refresh the channel for any user’s ban/unban. To reduce redundant datastore reads and UI updates, only refresh when the affected user is the current user.
Apply this diff:
- case is UserBannedEvent, - is UserUnbannedEvent: - updateChannelFromDataStore() + case let e as UserBannedEvent: + if let me = currentUserId, e.user.id == me { + updateChannelFromDataStore() + } + case let e as UserUnbannedEvent: + if let me = currentUserId, e.user.id == me { + updateChannelFromDataStore() + }DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift (1)
510-515
: Disable send when banned: consider also disabling input and surfacing copyThe override correctly disables sending. For a clearer UX (“Can’t send message”), consider also disabling text input and setting a placeholder when banned.
Apply this additional override in DemoLivestreamComposerVC:
+ override open func updatePlaceholderLabel() { + super.updatePlaceholderLabel() + if livestreamChannelController?.channel?.membership?.isBannedFromChannel == true { + composerView.inputMessageView.textView.isEditable = false + composerView.inputMessageView.placeholderLabel.text = "Can't send message" + } else { + composerView.inputMessageView.textView.isEditable = true + } + }Note: Since this is the demo app, hardcoded copy is acceptable; otherwise consider adding a localization key.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
CHANGELOG.md
(1 hunks)DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift
(2 hunks)Sources/StreamChat/Controllers/ChannelController/LivestreamChannelController.swift
(1 hunks)Tests/StreamChatTests/Controllers/ChannelController/LivestreamChannelController_Tests.swift
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift (2)
Sources/StreamChatUI/ChatMessageList/ChatMessageListView.swift (1)
updateContent
(76-76)Sources/StreamChatUI/Composer/ComposerVC.swift (1)
updateContent
(559-585)
Tests/StreamChatTests/Controllers/ChannelController/LivestreamChannelController_Tests.swift (6)
TestTools/StreamChatTestTools/TestData/DummyData/ChannelDetailPayload.swift (1)
dummy
(11-56)DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift (2)
channel
(220-222)eventsController
(397-410)Tests/StreamChatTests/Database/DTOs/ChannelDTO_Tests.swift (1)
channel
(1772-1774)TestTools/StreamChatTestTools/SpyPattern/Spy/DatabaseContainer_Spy.swift (1)
writeSynchronously
(175-182)Sources/StreamChat/Controllers/ChannelController/LivestreamChannelController.swift (2)
synchronize
(215-226)eventsController
(748-754)TestTools/StreamChatTestTools/SpyPattern/Spy/APIClient_Spy.swift (1)
test_simulateResponse
(108-111)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Automated Code Review
- GitHub Check: Build LLC + UI (Xcode 15)
- GitHub Check: Metrics
🔇 Additional comments (3)
CHANGELOG.md (1)
10-10
: Changelog entry aligns with implementationThe entry is accurate and scoped correctly to LivestreamChannelController. No further action needed.
DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift (1)
358-359
: Composer refresh on channel update looks goodUpdating the composer content after channel changes ensures the send-state is recalculated promptly. This directly supports the ban/unban UX.
Tests/StreamChatTests/Controllers/ChannelController/LivestreamChannelController_Tests.swift (1)
1360-1408
: LGTM: Ban event test verifies datastore-driven membership refreshThis test correctly seeds membership, flips isMemberBanned in the store, emits UserBannedEvent, and asserts in-memory state. Solid coverage.
Tests/StreamChatTests/Controllers/ChannelController/LivestreamChannelController_Tests.swift
Outdated
Show resolved
Hide resolved
SDK Performance
|
SDK Size
|
|
🔗 Issue Links
https://linear.app/stream/issue/IOS-1069/handle-user-banned-events-in-livestream-controlloer
🎯 Goal
Handle user-banned events in the livestream controller
🧪 Manual Testing Notes
☑️ Contributor Checklist
docs-content
repoSummary by CodeRabbit