Fix RocketChat/Rocket.Chat#329. Check for duplicate name before creating

channel or private group

Queried ChatRoom for Room with same name and returned a descriptive
error if one was found when creating a Channel or Private Group.
pull/330/head
Reid Wakida 11 years ago
parent be9b220fe1
commit 8ffddb1a59
  1. 4
      server/methods/createChannel.coffee
  2. 4
      server/methods/createPrivateGroup.coffee

@ -13,6 +13,10 @@ Meteor.methods
members.push user.username
# avoid duplicate names
if ChatRoom.findOne({name:name})
throw new Meteor.Error 'duplicate-name', "A Channel with the same name exists"
# name = s.slugify name
room =

@ -13,6 +13,10 @@ Meteor.methods
name = s.slugify name
# avoid duplicate names
if ChatRoom.findOne({name:name})
throw new Meteor.Error 'duplicate-name', "A private group with the same name exists"
# create new room
rid = ChatRoom.insert
usernames: members

Loading…
Cancel
Save