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/unarchiveRoom.coffee

22 lines
672 B

Meteor.methods
unArchiveRoom: (rid) ->
if not Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] unArchiveRoom -> Invalid user'
console.log '[methods] unArchiveRoom -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
room = ChatRoom.findOne rid
if room.u? and room.u._id is Meteor.userId() or Meteor.user().admin?
update =
$set:
archived: false
ChatRoom.update rid, update
for username in room.usernames
member = RocketChat.models.Users.findOneByUsername(username, { fields: { username: 1 }})
if not member?
continue
RocketChat.models.Subscriptions.unarchiveByRoomIdAndUserId rid, member._id