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

21 lines
763 B

Meteor.methods
archiveRoom: (rid) ->
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'archiveRoom' }
room = RocketChat.models.Rooms.findOneById rid
unless room
throw new Meteor.Error 'error-invalid-room', 'Invalid room', { method: 'archiveRoom' }
unless RocketChat.authz.hasPermission(Meteor.userId(), 'archive-room', room._id)
throw new Meteor.Error 'error-not-authorized', 'Not authorized', { method: 'archiveRoom' }
RocketChat.models.Rooms.archiveById rid
for username in room.usernames
member = RocketChat.models.Users.findOneByUsername(username, { fields: { username: 1 }})
if not member?
continue
RocketChat.models.Subscriptions.archiveByRoomIdAndUserId rid, member._id