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/packages/rocketchat-lib/server/methods/joinDefaultChannels.coffee

41 lines
985 B

Meteor.methods
joinDefaultChannels: ->
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] setUsername -> Invalid user")
console.log '[methods] joinDefaultChannels -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
user = Meteor.user()
ChatRoom.find({default: true, t: {$in: ['c', 'p']}}).forEach (room) ->
# put user in default rooms
ChatRoom.update room._id,
$addToSet:
usernames: user.username
if not ChatSubscription.findOne(rid: room._id, 'u._id': user._id)?
# Add a subscription to this user
ChatSubscription.insert
rid: room._id
name: room.name
ts: new Date()
t: room.t
f: false
open: true
alert: true
unread: 1
u:
_id: user._id
username: user.username
# Insert user joined message
ChatMessage.insert
rid: room._id
ts: new Date()
t: 'uj'
msg: ''
u:
_id: user._id
username: user.username