-
Couldn't load subscription status.
- Fork 225
Keep hidden state unchanged when receiving campaign message #3851
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
Keep hidden state unchanged when receiving campaign message #3851
Conversation
WalkthroughThe PR adds a Changes
Sequence DiagramsequenceDiagram
participant Client
participant Middleware as ChannelVisibilityEventMiddleware
participant ChannelDB as Channel Database
rect rgb(200, 220, 255)
Note over Client,ChannelDB: Regular Message Flow
Client->>Middleware: MessageNewEvent (no campaignId)
Middleware->>ChannelDB: Check isHidden & isShadowed
alt Not shadowed
Middleware->>ChannelDB: Set isHidden = false
end
end
rect rgb(220, 255, 200)
Note over Client,ChannelDB: Campaign Message Flow (NEW)
Client->>Middleware: MessageNewEvent (campaignId present)
Middleware->>ChannelDB: Check isHidden, isShadowed, & campaignId
alt Has campaignId
Middleware->>ChannelDB: Keep isHidden unchanged
else No campaignId and not shadowed
Middleware->>ChannelDB: Set isHidden = false
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
de4aede to
813bab4
Compare
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: 0
🧹 Nitpick comments (1)
Sources/StreamChat/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware.swift (1)
37-39: Consider adding inline documentation for campaign message exclusionThe logic correctly prevents campaign messages from unhiding channels, which aligns with the Campaign API's
show_channelsconfiguration controlling visibility. However, the reasoning might not be immediately obvious to future maintainers.Consider adding a brief comment explaining why campaign messages are excluded:
// Campaign messages don't unhide channels because visibility is controlled // by the Campaign API's show_channels configuration if !event.message.isShadowed && event.message.campaignId == nil && !channelDTO.isBlocked { channelDTO.isHidden = false }Also applies to: 48-50
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
CHANGELOG.md(1 hunks)Sources/StreamChat/APIClient/Endpoints/Payloads/MessagePayloads.swift(5 hunks)Sources/StreamChat/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware.swift(2 hunks)TestTools/StreamChatTestTools/TestData/DummyData/MessagePayload.swift(2 hunks)Tests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware_Tests.swift(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
**/*.swift: Respect .swiftlint.yml rules; do not suppress SwiftLint rules broadly—scope and justify any exceptions
Adhere to the project’s zero warnings policy—fix new warnings and avoid introducing any
Files:
Sources/StreamChat/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware.swiftTests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware_Tests.swiftTestTools/StreamChatTestTools/TestData/DummyData/MessagePayload.swiftSources/StreamChat/APIClient/Endpoints/Payloads/MessagePayloads.swift
Sources/{StreamChat,StreamChatUI}/**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
When altering public API, update inline documentation comments in source
Files:
Sources/StreamChat/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware.swiftSources/StreamChat/APIClient/Endpoints/Payloads/MessagePayloads.swift
CHANGELOG.md
📄 CodeRabbit inference engine (AGENTS.md)
Update CHANGELOG for user-visible SDK changes
Files:
CHANGELOG.md
Tests/{StreamChatTests,StreamChatUITests}/**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
Tests/{StreamChatTests,StreamChatUITests}/**/*.swift: Add or extend tests in the matching module’s Tests folder
Prefer using provided test fakes/mocks in tests when possible
Files:
Tests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware_Tests.swift
Tests/StreamChatTests/**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
Ensure tests cover core models and API surface of StreamChat
Files:
Tests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware_Tests.swift
🧬 Code graph analysis (1)
Tests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware_Tests.swift (5)
TestTools/StreamChatTestTools/TestData/DummyData/MessagePayload.swift (2)
dummy(11-106)dummy(124-142)Sources/StreamChat/Database/DatabaseSession.swift (1)
saveChannel(713-716)Sources/StreamChat/Database/DTOs/ChannelDTO.swift (3)
saveChannel(237-322)saveChannel(324-425)channel(427-429)TestTools/StreamChatTestTools/TestData/DummyData/XCTestCase+Dummy.swift (1)
dummyPayload(122-219)Sources/StreamChat/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware.swift (1)
handle(9-60)
⏰ 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). (1)
- GitHub Check: Metrics
🔇 Additional comments (4)
TestTools/StreamChatTestTools/TestData/DummyData/MessagePayload.swift (1)
57-58: LGTM - Test helper properly extended for campaignIdThe test helper correctly adds support for the new
campaignIdfield with an appropriate default value and properly propagates it to the MessagePayload initializer.Also applies to: 103-104
CHANGELOG.md (1)
15-15: LGTM - Changelog entry properly documents the fixThe changelog entry clearly describes the fix and is properly categorized under the "Fixed" section.
Tests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelVisibilityEventMiddleware_Tests.swift (1)
240-267: LGTM - Comprehensive test coverage for campaign messagesThe tests properly verify that campaign messages do not reset the
isHiddenflag for bothMessageNewEventandNotificationMessageNewEvent. The test structure is clear and follows the existing patterns in the test suite.Also applies to: 329-357
Sources/StreamChat/APIClient/Endpoints/Payloads/MessagePayloads.swift (1)
61-61: LGTM - campaignId field properly integrated into MessagePayloadThe
campaignIdfield is correctly added to the payload structure:
- Properly mapped to the backend field
created_by_campaign_id- Uses appropriate optional type
- Handled in all necessary locations (coding keys, property declaration, decoding, and initialization)
Also applies to: 125-126, 198-198, 244-245, 290-290
Public Interface🚀 No changes affecting the public interface. |
SDK Size
|
SDK Performance
|
StreamChat XCSize
|
|



🔗 Issue Links
Resolves: IOS-1194
🎯 Goal
Keep channel hidden state unchanged wen receiving campaign message
📝 Summary
show_channels: true/falseconfiguration🛠 Implementation
Campaign API has a setting called
show_channels. If it is true, channels are automatically shown, if false, hidden state is not changed. On the other hand SDKs support "Hiding a channel will remove it from query channel requests for that user until a new message is added." (docs). Only way for supporting both is opting out of showing channels on the SDK side when receiving a new message if the message is from campaign API.🎨 Showcase
🧪 Manual Testing Notes
Download the script
show_channels: false- channel does not appear in the channel listshow_channels: true- channel appears in the channel list☑️ Contributor Checklist
docs-contentrepoSummary by CodeRabbit