Skip to content

Commit

Permalink
Send a message on invite commands when the user doesn't exist or is a…
Browse files Browse the repository at this point in the history
…lready in the channel
  • Loading branch information
graywolf336 committed Oct 1, 2015
1 parent bedddfa commit caa7dfa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/rocketchat-slashcommands-invite/invite.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@ else
user = Meteor.users.findOne({ username: username })

if not user?
RocketChat.Notifications.notifyUser Meteor.userId(), 'message', {
_id: Random.id()
rid: item.rid
ts: new Date
msg: "No user exists by the name of `#{username}`."#TODO: Make this a language setting
}
return

# cancel if the user is already in this room
if RocketChat.models.Rooms.findOneByIdContainigUsername(item.rid, user.username)?
RocketChat.Notifications.notifyUser Meteor.userId(), 'message', {
_id: Random.id()
rid: item.rid
ts: new Date
msg: "`#{username}` is already in here."#TODO: Make this a language setting
}
return

Meteor.runAsUser user._id, ->
Expand Down

0 comments on commit caa7dfa

Please sign in to comment.