stream-chat-ruby 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +9 -1
- data/lib/stream-chat/channel.rb +22 -15
- data/lib/stream-chat/client.rb +28 -28
- data/lib/stream-chat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cff8888b576ad92ca17c3275504e585b1490e3935e7d86595aad795dfea67a7d
|
|
4
|
+
data.tar.gz: 8aa309ce84be59f966edee13e0e8957f863f59c535bc8df9d41d90484e8b1cb5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ca7b965ba2ca2fdffcb3ff667d93a1081e5aa15f40d3aeb9a167c945f26e54d3e773e826ca583c445c0da02acb5f67f3c450d7fc3fce98fcb958acd7e9077cf
|
|
7
|
+
data.tar.gz: 98b040deb4906b952d393244fb228843e77d669481104fa0ca75512cdcaacfccd75d8733c9ade31854366ab066ff6c58a54d2ff3c89e6c590d5a8c9fdc17c888
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -131,8 +131,16 @@ chan.unban_user('bob-1')
|
|
|
131
131
|
# Query channel state
|
|
132
132
|
chan.query({'messages' => { 'limit' => 10, 'id_lte' => m1['id']}})
|
|
133
133
|
|
|
134
|
+
# Update metadata (overwrite)
|
|
135
|
+
chan.update({'motd' => 'one apple a day....'})
|
|
136
|
+
|
|
137
|
+
# Update partial
|
|
138
|
+
# 1. key-value pairs to set
|
|
139
|
+
# 2. keys to unset (remove)
|
|
140
|
+
chan.update_partial({color: 'blue', age: 30}, ['motd'])
|
|
141
|
+
|
|
134
142
|
# Query channel members
|
|
135
|
-
chan.query_members({name: {'$autocomplete': 'test'}}, {last_created_at: -1}, offset: 5, limit: 5)
|
|
143
|
+
chan.query_members({name: {'$autocomplete': 'test'}}, sort: {last_created_at: -1}, offset: 5, limit: 5)
|
|
136
144
|
```
|
|
137
145
|
|
|
138
146
|
### Messages
|
data/lib/stream-chat/channel.rb
CHANGED
|
@@ -25,7 +25,7 @@ module StreamChat
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def send_message(message, user_id)
|
|
28
|
-
payload = {
|
|
28
|
+
payload = { message: add_user_id(message, user_id) }
|
|
29
29
|
@client.post("#{url}/message", data: payload)
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -35,24 +35,24 @@ module StreamChat
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def send_reaction(message_id, reaction, user_id)
|
|
38
|
-
payload = {
|
|
38
|
+
payload = { reaction: add_user_id(reaction, user_id) }
|
|
39
39
|
@client.post("messages/#{message_id}/reaction", data: payload)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def delete_reaction(message_id, reaction_type, user_id)
|
|
43
43
|
@client.delete(
|
|
44
44
|
"messages/#{message_id}/reaction/#{reaction_type}",
|
|
45
|
-
params: {
|
|
45
|
+
params: { user_id: user_id }
|
|
46
46
|
)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def create(user_id)
|
|
50
|
-
@custom_data['created_by'] = {
|
|
50
|
+
@custom_data['created_by'] = { id: user_id }
|
|
51
51
|
query(watch: false, state: false, presence: false)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def query(**options)
|
|
55
|
-
payload = {
|
|
55
|
+
payload = { state: true, data: @custom_data }.merge(options)
|
|
56
56
|
url = "channels/#{@channel_type}"
|
|
57
57
|
url = "#{url}/#{@id}" unless @id.nil?
|
|
58
58
|
|
|
@@ -61,7 +61,7 @@ module StreamChat
|
|
|
61
61
|
state
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
def query_members(filter_conditions
|
|
64
|
+
def query_members(filter_conditions = {}, sort: nil, **options)
|
|
65
65
|
params = {}.merge(options).merge({
|
|
66
66
|
id: @id,
|
|
67
67
|
type: @channel_type,
|
|
@@ -80,10 +80,17 @@ module StreamChat
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def update(channel_data, update_message = nil)
|
|
83
|
-
payload = {
|
|
83
|
+
payload = { data: channel_data, message: update_message }
|
|
84
84
|
@client.post(url, data: payload)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
def update_partial(set = nil, unset = nil)
|
|
88
|
+
raise StreamChannelException 'set or unset is needed' if set.nil? && unset.nil?
|
|
89
|
+
|
|
90
|
+
payload = { set: set, unset: unset }
|
|
91
|
+
@client.patch(url, data: payload)
|
|
92
|
+
end
|
|
93
|
+
|
|
87
94
|
def delete
|
|
88
95
|
@client.delete(url)
|
|
89
96
|
end
|
|
@@ -93,23 +100,23 @@ module StreamChat
|
|
|
93
100
|
end
|
|
94
101
|
|
|
95
102
|
def add_members(user_ids)
|
|
96
|
-
@client.post(url, data: {
|
|
103
|
+
@client.post(url, data: { add_members: user_ids })
|
|
97
104
|
end
|
|
98
105
|
|
|
99
106
|
def invite_members(user_ids)
|
|
100
|
-
@client.post(url, data: {
|
|
107
|
+
@client.post(url, data: { invites: user_ids })
|
|
101
108
|
end
|
|
102
109
|
|
|
103
110
|
def add_moderators(user_ids)
|
|
104
|
-
@client.post(url, data: {
|
|
111
|
+
@client.post(url, data: { add_moderators: user_ids })
|
|
105
112
|
end
|
|
106
113
|
|
|
107
114
|
def remove_members(user_ids)
|
|
108
|
-
@client.post(url, data: {
|
|
115
|
+
@client.post(url, data: { remove_members: user_ids })
|
|
109
116
|
end
|
|
110
117
|
|
|
111
118
|
def demote_moderators(user_ids)
|
|
112
|
-
@client.post(url, data: {
|
|
119
|
+
@client.post(url, data: { demote_moderators: user_ids })
|
|
113
120
|
end
|
|
114
121
|
|
|
115
122
|
def mark_read(user_id, **options)
|
|
@@ -150,17 +157,17 @@ module StreamChat
|
|
|
150
157
|
end
|
|
151
158
|
|
|
152
159
|
def delete_file(url)
|
|
153
|
-
@client.delete("#{self.url}/file", params: {
|
|
160
|
+
@client.delete("#{self.url}/file", params: { url: url })
|
|
154
161
|
end
|
|
155
162
|
|
|
156
163
|
def delete_image(url)
|
|
157
|
-
@client.delete("#{self.url}/image", params: {
|
|
164
|
+
@client.delete("#{self.url}/image", params: { url: url })
|
|
158
165
|
end
|
|
159
166
|
|
|
160
167
|
private
|
|
161
168
|
|
|
162
169
|
def add_user_id(payload, user_id)
|
|
163
|
-
payload.merge({
|
|
170
|
+
payload.merge({ user: { id: user_id } })
|
|
164
171
|
end
|
|
165
172
|
end
|
|
166
173
|
end
|
data/lib/stream-chat/client.rb
CHANGED
|
@@ -60,22 +60,22 @@ module StreamChat
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def flag_message(id, **options)
|
|
63
|
-
payload = {
|
|
63
|
+
payload = { target_message_id: id }.merge(options)
|
|
64
64
|
post('moderation/flag', data: payload)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def unflag_message(id, **options)
|
|
68
|
-
payload = {
|
|
68
|
+
payload = { target_message_id: id }.merge(options)
|
|
69
69
|
post('moderation/unflag', data: payload)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def flag_user(id, **options)
|
|
73
|
-
payload = {
|
|
73
|
+
payload = { target_user_id: id }.merge(options)
|
|
74
74
|
post('moderation/flag', data: payload)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def unflag_user(id, **options)
|
|
78
|
-
payload = {
|
|
78
|
+
payload = { target_user_id: id }.merge(options)
|
|
79
79
|
post('moderation/unflag', data: payload)
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -85,11 +85,11 @@ module StreamChat
|
|
|
85
85
|
|
|
86
86
|
def search(filter_conditions, query, **options)
|
|
87
87
|
params = options.merge({
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
filter_conditions: filter_conditions,
|
|
89
|
+
query: query
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
-
get('search', params: {
|
|
92
|
+
get('search', params: { payload: params.to_json })
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def update_users(users)
|
|
@@ -100,7 +100,7 @@ module StreamChat
|
|
|
100
100
|
|
|
101
101
|
payload[id] = user
|
|
102
102
|
end
|
|
103
|
-
post('users', data: {
|
|
103
|
+
post('users', data: { users: payload })
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def update_user(user)
|
|
@@ -108,7 +108,7 @@ module StreamChat
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def update_users_partial(updates)
|
|
111
|
-
patch('users', data: {
|
|
111
|
+
patch('users', data: { users: updates })
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
def update_user_partial(update)
|
|
@@ -132,34 +132,34 @@ module StreamChat
|
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def ban_user(target_id, **options)
|
|
135
|
-
payload = {
|
|
135
|
+
payload = { target_user_id: target_id }.merge(options)
|
|
136
136
|
post('moderation/ban', data: payload)
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def unban_user(target_id, **options)
|
|
140
|
-
params = {
|
|
140
|
+
params = { target_user_id: target_id }.merge(options)
|
|
141
141
|
delete('moderation/ban', params: params)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
def mute_user(target_id, user_id)
|
|
145
|
-
payload = {
|
|
145
|
+
payload = { target_id: target_id, user_id: user_id }
|
|
146
146
|
post('moderation/mute', data: payload)
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
def unmute_user(target_id, user_id)
|
|
150
|
-
payload = {
|
|
150
|
+
payload = { target_id: target_id, user_id: user_id }
|
|
151
151
|
post('moderation/unmute', data: payload)
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
def mark_all_read(user_id)
|
|
155
|
-
payload = {
|
|
155
|
+
payload = { user: { id: user_id } }
|
|
156
156
|
post('channels/read', data: payload)
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
def update_message(message)
|
|
160
160
|
raise ArgumentError 'message must have an id' unless message.key? 'id'
|
|
161
161
|
|
|
162
|
-
post("messages/#{message['id']}", data: {
|
|
162
|
+
post("messages/#{message['id']}", data: { message: message })
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
def delete_message(message_id)
|
|
@@ -168,14 +168,14 @@ module StreamChat
|
|
|
168
168
|
|
|
169
169
|
def query_users(filter_conditions, sort: nil, **options)
|
|
170
170
|
params = options.merge({
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
filter_conditions: filter_conditions,
|
|
172
|
+
sort: get_sort_fields(sort)
|
|
173
173
|
})
|
|
174
|
-
get('users', params: {
|
|
174
|
+
get('users', params: { payload: params.to_json })
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
def query_channels(filter_conditions, sort: nil, **options)
|
|
178
|
-
data = {
|
|
178
|
+
data = { state: true, watch: false, presence: false }
|
|
179
179
|
data = data.merge(options).merge({
|
|
180
180
|
filter_conditions: filter_conditions,
|
|
181
181
|
sort: get_sort_fields(sort)
|
|
@@ -218,18 +218,18 @@ module StreamChat
|
|
|
218
218
|
|
|
219
219
|
def add_device(device_id, push_provider, user_id)
|
|
220
220
|
post('devices', data: {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
id: device_id,
|
|
222
|
+
push_provider: push_provider,
|
|
223
|
+
user_id: user_id
|
|
224
224
|
})
|
|
225
225
|
end
|
|
226
226
|
|
|
227
227
|
def delete_device(device_id, user_id)
|
|
228
|
-
delete('devices', params: {
|
|
228
|
+
delete('devices', params: { id: device_id, user_id: user_id })
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
def get_devices(user_id)
|
|
232
|
-
get('devices', params: {
|
|
232
|
+
get('devices', params: { user_id: user_id })
|
|
233
233
|
end
|
|
234
234
|
|
|
235
235
|
def verify_webhook(request_body, x_signature)
|
|
@@ -246,11 +246,11 @@ module StreamChat
|
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
def create_blocklist(name, words)
|
|
249
|
-
post('blocklists', data: {
|
|
249
|
+
post('blocklists', data: { name: name, words: words })
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
def update_blocklist(name, words)
|
|
253
|
-
put("blocklists/#{name}", data: {
|
|
253
|
+
put("blocklists/#{name}", data: { words: words })
|
|
254
254
|
end
|
|
255
255
|
|
|
256
256
|
def delete_blocklist(name)
|
|
@@ -258,7 +258,7 @@ module StreamChat
|
|
|
258
258
|
end
|
|
259
259
|
|
|
260
260
|
def export_channels(*channels)
|
|
261
|
-
post('export_channels', data: {
|
|
261
|
+
post('export_channels', data: { channels: channels })
|
|
262
262
|
end
|
|
263
263
|
|
|
264
264
|
def get_export_channel_status(task_id)
|
|
@@ -305,7 +305,7 @@ module StreamChat
|
|
|
305
305
|
end
|
|
306
306
|
|
|
307
307
|
def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
|
|
308
|
-
post('check_sqs', data: {
|
|
308
|
+
post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
private
|
data/lib/stream-chat/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stream-chat-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mircea Cosbuc
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|