pusher-chatkit-server 0.5.2 → 0.6.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 +2 -13
- metadata +1 -2
- data/lib/chatkit/permissions.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e59b191b0f78f2ac773eff61618e1860789d1254
|
4
|
+
data.tar.gz: 1c0528a31ffc3ef53df7537c78e3725ceb8271f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b297eeddab0bf4629b066346c9279c54063f204377ccf3f31b13263d29c62f1f4a7ca12e26061bf40496d1f4dc5dca34ae659ffca2fec804692b1300d9b8a96c
|
7
|
+
data.tar.gz: efb025d3f59fc80151111ab6924b153c88e29d3a1f252d7b582147166a99616c12f7f2e56676566398444e5b8b539d3f6a68a806dbd95f0350adc4e746cb114a
|
data/lib/chatkit/client.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'pusher-platform'
|
2
2
|
require 'json'
|
3
|
-
require_relative './permissions'
|
4
3
|
|
5
4
|
module Chatkit
|
5
|
+
ROOM_SCOPE = "room"
|
6
|
+
GLOBAL_SCOPE = "global"
|
6
7
|
|
7
8
|
class Error < RuntimeError
|
8
9
|
end
|
@@ -208,8 +209,6 @@ module Chatkit
|
|
208
209
|
end
|
209
210
|
|
210
211
|
def update_role_permissions(role_name, scope, permissions_to_add = [], permissions_to_remove = [])
|
211
|
-
check_permissions(permissions_to_add+permissions_to_remove, scope)
|
212
|
-
|
213
212
|
if permissions_to_add.empty? && permissions_to_remove.empty?
|
214
213
|
raise Chatkit::Error.new("permissions_to_add and permissions_to_remove cannot both be empty")
|
215
214
|
end
|
@@ -232,8 +231,6 @@ module Chatkit
|
|
232
231
|
private
|
233
232
|
|
234
233
|
def create_role(name, scope, permissions)
|
235
|
-
check_permissions(permissions, scope)
|
236
|
-
|
237
234
|
@authorizer_instance.request(
|
238
235
|
method: "POST",
|
239
236
|
path: "/roles",
|
@@ -302,13 +299,5 @@ module Chatkit
|
|
302
299
|
|
303
300
|
JSON.parse(resp.body)
|
304
301
|
end
|
305
|
-
|
306
|
-
def check_permissions(permissions, scope)
|
307
|
-
permissions.each do |permission|
|
308
|
-
unless VALID_PERMISSIONS[scope.to_sym].include?(permission)
|
309
|
-
raise Chatkit::Error.new("Permission value #{permission} is invalid")
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
313
302
|
end
|
314
303
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pusher
|
@@ -32,7 +32,6 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- lib/chatkit.rb
|
34
34
|
- lib/chatkit/client.rb
|
35
|
-
- lib/chatkit/permissions.rb
|
36
35
|
homepage:
|
37
36
|
licenses:
|
38
37
|
- MIT
|
data/lib/chatkit/permissions.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module Chatkit
|
2
|
-
ROOM_SCOPE = "room"
|
3
|
-
GLOBAL_SCOPE = "global"
|
4
|
-
|
5
|
-
JOIN_ROOM = "room:join"
|
6
|
-
LEAVE_ROOM = "room:leave"
|
7
|
-
ADD_ROOM_MEMBER = "room:members:add"
|
8
|
-
REMOVE_ROOM_MEMBER = "room:members:remove"
|
9
|
-
CREATE_ROOM = "room:create"
|
10
|
-
DELETE_ROOM = "room:delete"
|
11
|
-
UPDATE_ROOM = "room:update"
|
12
|
-
CREATE_MESSAGE = "message:create"
|
13
|
-
CREATE_TYPING_EVENT = "room:typing_indicator:create"
|
14
|
-
SUBSCRIBE_PRESENCE = "presence:subscribe"
|
15
|
-
UPDATE_USER = "user:update"
|
16
|
-
GET_ROOM_MESSAGES = "room:messages:get"
|
17
|
-
GET_USER = "user:get"
|
18
|
-
GET_ROOM = "room:get"
|
19
|
-
GET_USER_ROOMS = "user:rooms:get"
|
20
|
-
CREATE_FILE = "file:create"
|
21
|
-
GET_FILE = "file:get"
|
22
|
-
CURSOR_READ_GET = "cursors:read:get"
|
23
|
-
CURSOR_READ_SET = "cursors:read:set"
|
24
|
-
|
25
|
-
VALID_PERMISSIONS = {
|
26
|
-
room: [
|
27
|
-
JOIN_ROOM,
|
28
|
-
LEAVE_ROOM,
|
29
|
-
ADD_ROOM_MEMBER,
|
30
|
-
REMOVE_ROOM_MEMBER,
|
31
|
-
DELETE_ROOM,
|
32
|
-
UPDATE_ROOM,
|
33
|
-
CREATE_MESSAGE,
|
34
|
-
CREATE_TYPING_EVENT,
|
35
|
-
GET_ROOM_MESSAGES,
|
36
|
-
CREATE_FILE,
|
37
|
-
GET_FILE,
|
38
|
-
CURSOR_READ_GET,
|
39
|
-
CURSOR_READ_SET
|
40
|
-
],
|
41
|
-
global: [
|
42
|
-
JOIN_ROOM,
|
43
|
-
LEAVE_ROOM,
|
44
|
-
ADD_ROOM_MEMBER,
|
45
|
-
REMOVE_ROOM_MEMBER,
|
46
|
-
CREATE_ROOM,
|
47
|
-
DELETE_ROOM,
|
48
|
-
UPDATE_ROOM,
|
49
|
-
CREATE_MESSAGE,
|
50
|
-
CREATE_TYPING_EVENT,
|
51
|
-
SUBSCRIBE_PRESENCE,
|
52
|
-
UPDATE_USER,
|
53
|
-
GET_ROOM_MESSAGES,
|
54
|
-
GET_USER,
|
55
|
-
GET_ROOM,
|
56
|
-
GET_USER_ROOMS,
|
57
|
-
CREATE_FILE,
|
58
|
-
GET_FILE,
|
59
|
-
CURSOR_READ_GET,
|
60
|
-
CURSOR_READ_SET
|
61
|
-
]
|
62
|
-
}
|
63
|
-
end
|