Skip to content
Snippets Groups Projects
Commit 0d7f4746 authored by Gabriel Engel's avatar Gabriel Engel
Browse files

re organising files

parent 9682c27e
No related branches found
No related tags found
No related merge requests found
......@@ -3,48 +3,42 @@
# @param {Object} message - The message object
###
if Meteor.isClient
Tracker.autorun ->
RocketChat.slashCommands.add 'invite', undefined,
description: TAPi18n.__('Invite_user_to_join_channel')
params: '@username'
else
class Invite
constructor: (command, params, item) ->
if command isnt 'invite' or not Match.test params, String
return
username = params.trim()
if username is ''
return
username = username.replace('@', '')
user = Meteor.users.findOne({ username: username })
currentUser = Meteor.users.findOne Meteor.userId()
if not user?
console.log 'notify user_doesnt_exist'
RocketChat.Notifications.notifyUser Meteor.userId(), 'message', {
_id: Random.id()
rid: item.rid
ts: new Date
msg: TAPi18n.__('User_doesnt_exist', { postProcess: 'sprintf', sprintf: [ username ] }, currentUser.language)
}
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: TAPi18n.__('Username_is_already_in_here', { postProcess: 'sprintf', sprintf: [ username ] }, currentUser.language)
}
return
Meteor.runAsUser user._id, ->
Meteor.call 'joinRoom', item.rid
RocketChat.slashCommands.add 'invite', Invite
class Invite
constructor: (command, params, item) ->
if command isnt 'invite' or not Match.test params, String
return
username = params.trim()
if username is ''
return
username = username.replace('@', '')
user = Meteor.users.findOne({ username: username })
currentUser = Meteor.users.findOne Meteor.userId()
if not user?
console.log 'notify user_doesnt_exist'
RocketChat.Notifications.notifyUser Meteor.userId(), 'message', {
_id: Random.id()
rid: item.rid
ts: new Date
msg: TAPi18n.__('User_doesnt_exist', { postProcess: 'sprintf', sprintf: [ username ] }, currentUser.language)
}
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: TAPi18n.__('Username_is_already_in_here', { postProcess: 'sprintf', sprintf: [ username ] }, currentUser.language)
}
return
Meteor.runAsUser user._id, ->
Meteor.call 'joinRoom', item.rid
RocketChat.slashCommands.add 'invite', Invite
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment