The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/publications/filteredUsers.coffee

34 lines
661 B

Meteor.publish 'filteredUsers', (name) ->
unless this.userId
return this.ready()
console.log '[publish] filteredUsers'.green, name
exp = new RegExp(name, 'i')
options =
fields:
username: 1
name: 1
status: 1
utcOffset: 1
sort:
lastLogin: -1
limit: 5
pub = this
cursorHandle = RocketChat.models.Users.findUsersByNameOrUsername(exp, options).observeChanges
added: (_id, record) ->
pub.added('filtered-users', _id, record)
changed: (_id, record) ->
pub.changed('filtered-users', _id, record)
removed: (_id, record) ->
pub.removed('filtered-users', _id, record)
@ready()
@onStop ->
cursorHandle.stop()
return