parent
aa6d0265e0
commit
6789facdfc
@ -0,0 +1,15 @@ |
||||
Meteor.methods |
||||
getRoomModerators: (rid) -> |
||||
unless Meteor.userId() |
||||
throw new Meteor.Error 'invalid-user', '[methods] getRoomModerators -> Invalid user' |
||||
|
||||
check rid, String |
||||
|
||||
options = |
||||
sort: |
||||
"u.username": 1 |
||||
fields: |
||||
rid: 1 |
||||
u: 1 |
||||
|
||||
return RocketChat.models.Subscriptions.findByRoomIdAndRoles(rid, 'moderator', options).fetch() |
||||
@ -1,32 +0,0 @@ |
||||
Meteor.publish 'roomModerators', (rid, limit = 50) -> |
||||
unless this.userId |
||||
return this.ready() |
||||
|
||||
pub = this |
||||
|
||||
query = |
||||
rid: rid |
||||
roles: 'moderator' |
||||
|
||||
options = |
||||
limit: limit |
||||
sort: |
||||
"u.username": 1 |
||||
fields: |
||||
rid: 1 |
||||
u: 1 |
||||
|
||||
cursor = RocketChat.models.Subscriptions.find(query, options).observeChanges |
||||
added: (_id, record) -> |
||||
pub.added('room_moderators', _id, record) |
||||
|
||||
changed: (_id, record) -> |
||||
pub.changed('room_moderators', _id, record) |
||||
|
||||
removed: (_id, record) -> |
||||
pub.removed('room_moderators', _id, record) |
||||
|
||||
this.ready() |
||||
this.onStop -> |
||||
cursor.stop() |
||||
|
||||
Loading…
Reference in new issue