-
Notifications
You must be signed in to change notification settings - Fork 11.3k
/
Copy pathroomPublishes.coffee
53 lines (48 loc) · 1.44 KB
/
roomPublishes.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Meteor.startup ->
RocketChat.roomTypes.setPublish 'c', (identifier) ->
options =
fields:
name: 1
t: 1
cl: 1
u: 1
usernames: 1
topic: 1
muted: 1
archived: 1
jitsiTimeout: 1
if RocketChat.authz.hasPermission(this.userId, 'view-c-room')
return RocketChat.models.Rooms.findByTypeAndName 'c', identifier, options
else if RocketChat.authz.hasPermission(this.userId, 'view-joined-room')
roomId = RocketChat.models.Subscriptions.findByTypeNameAndUserId('c', identifier, this.userId).fetch()
if roomId.length > 0
return RocketChat.models.Rooms.findById(roomId[0]?.rid, options)
return this.ready()
RocketChat.roomTypes.setPublish 'p', (identifier) ->
options =
fields:
name: 1
t: 1
cl: 1
u: 1
usernames: 1
topic: 1
muted: 1
archived: 1
jitsiTimeout: 1
user = RocketChat.models.Users.findOneById this.userId, fields: username: 1
return RocketChat.models.Rooms.findByTypeAndNameContainingUsername 'p', identifier, user.username, options
RocketChat.roomTypes.setPublish 'd', (identifier) ->
options =
fields:
name: 1
t: 1
cl: 1
u: 1
usernames: 1
topic: 1
jitsiTimeout: 1
user = RocketChat.models.Users.findOneById this.userId, fields: username: 1
if RocketChat.authz.hasPermission(this.userId, 'view-d-room')
return RocketChat.models.Rooms.findByTypeContainigUsernames 'd', [user.username, identifier], options
return this.ready()