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

36 lines
696 B

Meteor.methods
saveRoomName: (data) ->
fromId = Meteor.userId()
# console.log '[methods] saveRoomName -> '.green, 'fromId:', fromId, 'data:', data
room = ChatRoom.findOne data.rid
if room.u._id isnt Meteor.userId() or room.t not in ['c', 'p']
throw new Meteor.Error 403, 'Not allowed'
newName = _.slugify data.name
if newName is room.name
return
ChatRoom.update data.rid,
$set:
name: newName
nc: true
ChatSubscription.update { rid: data.rid },
$set:
name: newName
,
multi: true
ChatMessage.insert
rid: data.rid
ts: (new Date)
t: 'r'
msg: newName
u:
_id: Meteor.userId()
username: Meteor.user().username
return true