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/methods/forwardRoom.coffee

38 lines
891 B

Meteor.methods
forwardRoom: (forward) ->
fromId = Meteor.userId()
# console.log '[methods] forwardRoom -> '.green, 'fromId:', fromId, 'forward:', forward
# @TODO implementar validação para não poder convidar quem já está na sala
now = new Date()
userTo = Meteor.users.findOne forward.to
unless userTo?
throw new Meteor.Error 203, 'Usuário não encontrado'
room = ChatRoom.findOne forward.rid
ChatRoom.update forward.rid,
$addToSet:
uids: forward.to
# $pull:
# uids: Meteor.userId()
ChatSubscription.upsert { rid: forward.rid, $and: [{'u._id': forward.to}] },
$setOnInsert:
'u._id': forward.to
rn: room.name
t: 'v'
unread: 0
$set:
ts: now
ChatMessage.insert
rid: forward.rid
ts: now
t: 'au'
msg: userTo.name
by: Meteor.userId()
# ChatSubscription.remove { rid: forward.rid, uid: Meteor.userId() }