Skip to content

Commit aac72b1

Browse files
committed
fix: use correct params
1 parent 079e199 commit aac72b1

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

lib/stream-chat/channel.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,15 @@ def query(**options)
101101
# Updates the channel's members attribute with fresh data.
102102
sig { returns(StreamChat::StreamResponse) }
103103
def refresh_state
104-
state = query_members
105-
@members = state['members'] if state['members']
104+
url = "channels/#{@channel_type}/#{@id}/query"
105+
state = @client.post(url, data: { state: true })
106+
107+
# Members can be at top level or inside channel object (like Go's updateChannel)
108+
if state['members'] && !state['members'].empty?
109+
@members = state['members']
110+
elsif state['channel'] && state['channel']['members']
111+
@members = state['channel']['members']
112+
end
106113
state
107114
end
108115

spec/channel_batch_updater_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def wait_for_task(task_id, timeout_seconds: 120)
109109
response = @client.update_channels_batch(
110110
{
111111
operation: 'addMembers',
112-
filter: { cid: { '$in' => [@channel1.cid, @channel2.cid] } },
112+
filter: { cids: { '$in' => [@channel1.cid, @channel2.cid] } },
113113
members: [{ 'user_id' => @random_users[0][:id] }]
114114
}
115115
)
@@ -125,7 +125,7 @@ def wait_for_task(task_id, timeout_seconds: 120)
125125
member_ids = @random_users.map { |u| u[:id] }
126126
members = member_ids.map { |id| { 'user_id' => id } }
127127
response = updater.add_members(
128-
{ cid: { '$in' => [@channel1.cid, @channel2.cid] } },
128+
{ cids: { '$in' => [@channel1.cid, @channel2.cid] } },
129129
members
130130
)
131131

@@ -186,7 +186,7 @@ def wait_for_task(task_id, timeout_seconds: 120)
186186
member_to_remove = members_to_add[0]
187187

188188
response = updater.remove_members(
189-
{ cid: { '$in' => [@channel1.cid, @channel2.cid] } },
189+
{ cids: { '$in' => [@channel1.cid, @channel2.cid] } },
190190
[{ 'user_id' => member_to_remove }]
191191
)
192192

@@ -233,7 +233,7 @@ def wait_for_task(task_id, timeout_seconds: 120)
233233
member_to_archive = members_to_add[0]
234234

235235
response = updater.archive(
236-
{ cid: { '$in' => [@channel1.cid, @channel2.cid] } },
236+
{ cids: { '$in' => [@channel1.cid, @channel2.cid] } },
237237
[{ 'user_id' => member_to_archive }]
238238
)
239239

0 commit comments

Comments
 (0)