-
Notifications
You must be signed in to change notification settings - Fork 21
[CHA-1610] Add support channels batch update #188
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
Open
rafaelmf3
wants to merge
1
commit into
master
Choose a base branch
from
cha-1610-update-channels-batch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,211 @@ | ||
| # typed: strict | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'stream-chat/client' | ||
| require 'stream-chat/stream_response' | ||
| require 'stream-chat/types' | ||
|
|
||
| module StreamChat | ||
| class ChannelBatchUpdater | ||
| extend T::Sig | ||
|
|
||
| sig { params(client: StreamChat::Client).void } | ||
| def initialize(client) | ||
| @client = client | ||
| end | ||
|
|
||
| # Member operations | ||
|
|
||
| # addMembers - Add members to channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param members [T.any(T::Array[String], T::Array[StringKeyHash])] Members to add | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, members: T.any(T::Array[String], T::Array[StringKeyHash])).returns(StreamChat::StreamResponse) } | ||
| def add_members(filter, members) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'addMembers', | ||
| filter: filter, | ||
| members: members | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # removeMembers - Remove members from channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param members [T::Array[String]] Member IDs to remove | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, members: T::Array[String]).returns(StreamChat::StreamResponse) } | ||
| def remove_members(filter, members) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'removeMembers', | ||
| filter: filter, | ||
| members: members | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # inviteMembers - Invite members to channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param members [T.any(T::Array[String], T::Array[StringKeyHash])] Members to invite | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, members: T.any(T::Array[String], T::Array[StringKeyHash])).returns(StreamChat::StreamResponse) } | ||
| def invite_members(filter, members) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'invites', | ||
| filter: filter, | ||
| members: members | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # addModerators - Add moderators to channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param members [T::Array[String]] Member IDs to promote to moderator | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, members: T::Array[String]).returns(StreamChat::StreamResponse) } | ||
| def add_moderators(filter, members) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'addModerators', | ||
| filter: filter, | ||
| members: members | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # demoteModerators - Remove moderator role from members in channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param members [T::Array[String]] Member IDs to demote | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, members: T::Array[String]).returns(StreamChat::StreamResponse) } | ||
| def demote_moderators(filter, members) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'demoteModerators', | ||
| filter: filter, | ||
| members: members | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # assignRoles - Assign roles to members in channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param members [T::Array[StringKeyHash]] Members with role assignments | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, members: T::Array[StringKeyHash]).returns(StreamChat::StreamResponse) } | ||
| def assign_roles(filter, members) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'assignRoles', | ||
| filter: filter, | ||
| members: members | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # Visibility operations | ||
|
|
||
| # hide - Hide channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash).returns(StreamChat::StreamResponse) } | ||
| def hide(filter) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'hide', | ||
| filter: filter | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # show - Show channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash).returns(StreamChat::StreamResponse) } | ||
| def show(filter) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'show', | ||
| filter: filter | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # archive - Archive channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash).returns(StreamChat::StreamResponse) } | ||
| def archive(filter) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'archive', | ||
| filter: filter | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # unarchive - Unarchive channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash).returns(StreamChat::StreamResponse) } | ||
| def unarchive(filter) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'unarchive', | ||
| filter: filter | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # Data operations | ||
|
|
||
| # updateData - Update data on channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param data [StringKeyHash] Data to update | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, data: StringKeyHash).returns(StreamChat::StreamResponse) } | ||
| def update_data(filter, data) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'updateData', | ||
| filter: filter, | ||
| data: data | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # addFilterTags - Add filter tags to channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param tags [T::Array[String]] Tags to add | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, tags: T::Array[String]).returns(StreamChat::StreamResponse) } | ||
| def add_filter_tags(filter, tags) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'addFilterTags', | ||
| filter: filter, | ||
| filter_tags_update: tags | ||
| } | ||
| ) | ||
| end | ||
|
|
||
| # removeFilterTags - Remove filter tags from channels matching the filter | ||
| # @param filter [StringKeyHash] Filter to select channels | ||
| # @param tags [T::Array[String]] Tags to remove | ||
| # @return [StreamChat::StreamResponse] The server response | ||
| sig { params(filter: StringKeyHash, tags: T::Array[String]).returns(StreamChat::StreamResponse) } | ||
| def remove_filter_tags(filter, tags) | ||
| @client.update_channels_batch( | ||
| { | ||
| operation: 'removeFilterTags', | ||
| filter: filter, | ||
| filter_tags_update: tags | ||
| } | ||
| ) | ||
| end | ||
| end | ||
| end | ||
|
|
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
Oops, something went wrong.
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.
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.
📝 [rubocop] <Layout/TrailingEmptyLines> reported by reviewdog 🐶
1 trailing blank lines detected.
https://github.com/GetStream/stream-chat-ruby/blob/3ff3f45e30d9c29f99932565af2f537f0608a5d4/lib/stream-chat/channel_batch_updater.rb#L211-L212