pusher-chatkit-server 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chatkit/client.rb +33 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d8705e035eae037bd66b18d5d86cb8d7acc8e52
|
4
|
+
data.tar.gz: 4ec9d238c823dbb29b43240e1494f3a9959dbe23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3dd6653c0f38d26cb5245af0c5331b9bea874b2aedb1677a1197632f34d9fb61052a928b11be0e9caf607071541bbeae1eacf143716b1889850143ea5f80c7
|
7
|
+
data.tar.gz: 3b838cc62123214d0a0c81ae7e5dda9841f7ba4929ae9305aec078809b92736f7777e4c09b6c4127e3419013fc639187c2bdae35a799a62c1ffd107ce772db1d
|
data/lib/chatkit/client.rb
CHANGED
@@ -65,7 +65,7 @@ module Chatkit
|
|
65
65
|
"Content-Type": "application/json",
|
66
66
|
},
|
67
67
|
body: body,
|
68
|
-
jwt: generate_access_token(
|
68
|
+
jwt: generate_access_token(su: true)
|
69
69
|
)
|
70
70
|
end
|
71
71
|
|
@@ -73,7 +73,7 @@ module Chatkit
|
|
73
73
|
@api_instance.request(
|
74
74
|
method: "DELETE",
|
75
75
|
path: "/users/#{id}",
|
76
|
-
jwt: generate_access_token(
|
76
|
+
jwt: generate_access_token(su: true)
|
77
77
|
)
|
78
78
|
end
|
79
79
|
|
@@ -211,14 +211,32 @@ module Chatkit
|
|
211
211
|
get_permissions_for_role(role_name, ROOM_SCOPE)
|
212
212
|
end
|
213
213
|
|
214
|
+
def update_role_permissions(role_name, scope, permissions_to_add, permissions_to_remove)
|
215
|
+
check_permissions(permissions_to_add+permissions_to_remove)
|
216
|
+
|
217
|
+
if permissions_to_add.empty? && permissions_to_remove.empty?
|
218
|
+
raise Chatkit::Error.new("permissions_to_add and permissions_to_remove cannot both be empty")
|
219
|
+
end
|
220
|
+
|
221
|
+
body = {}
|
222
|
+
body[:add_permissions] = permissions_to_add unless permissions_to_add.empty?
|
223
|
+
body[:remove_permissions] = permissions_to_remove unless permissions_to_remove.empty?
|
224
|
+
|
225
|
+
@authorizer_instance.request(
|
226
|
+
method: "PUT",
|
227
|
+
path: "/roles/#{role_name}/scope/#{scope}/permissions"
|
228
|
+
headers: {
|
229
|
+
"Content-Type": "application/json"
|
230
|
+
},
|
231
|
+
body: body,
|
232
|
+
jwt: generate_access_token(su: true)
|
233
|
+
)
|
234
|
+
end
|
235
|
+
|
214
236
|
private
|
215
237
|
|
216
238
|
def create_role(name, scope, permissions)
|
217
|
-
permissions
|
218
|
-
unless VALID_PERMISSIONS[scope.to_sym].include?(permission)
|
219
|
-
raise Chatkit::Error.new("Permission value #{permission} is invalid")
|
220
|
-
end
|
221
|
-
end
|
239
|
+
check_permissions(permissions)
|
222
240
|
|
223
241
|
@authorizer_instance.request(
|
224
242
|
method: "POST",
|
@@ -306,5 +324,13 @@ module Chatkit
|
|
306
324
|
|
307
325
|
JSON.parse(resp.body)
|
308
326
|
end
|
327
|
+
|
328
|
+
def check_permissions(permissions)
|
329
|
+
permissions.each do |permission|
|
330
|
+
unless VALID_PERMISSIONS[scope.to_sym].include?(permission)
|
331
|
+
raise Chatkit::Error.new("Permission value #{permission} is invalid")
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
309
335
|
end
|
310
336
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher-chatkit-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pusher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pusher-platform
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.6.
|
56
|
+
rubygems_version: 2.6.12
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Pusher Chatkit Ruby SDK
|