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

25 lines
883 B

Meteor.methods
removeRoomOwner: (rid, userId) ->
unless Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] removeRoomOwner -> Invalid user'
check rid, String
check userId, String
unless RocketChat.authz.hasPermission Meteor.userId(), 'set-owner', rid
throw new Meteor.Error 403, 'Not allowed'
subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId rid, userId
unless subscription?
throw new Meteor.Error 'invalid-subscription', '[methods] removeRoomOwner -> Invalid Subscription'
RocketChat.models.Subscriptions.removeRoleById(subscription._id, 'owner')
user = RocketChat.models.Users.findOneById userId
fromUser = RocketChat.models.Users.findOneById Meteor.userId()
RocketChat.models.Messages.createOwnerRemovedWithRoomIdAndUser rid, user,
u:
_id: fromUser._id
username: fromUser.username
return true