diff --git a/back/methods/chat/sendMessage.js b/back/methods/chat/sendMessage.js new file mode 100644 index 000000000..b6eaf79a8 --- /dev/null +++ b/back/methods/chat/sendMessage.js @@ -0,0 +1,30 @@ +module.exports = Self => { + Self.remoteMethodCtx('sendMessage', { + description: 'Send a RocketChat message', + accessType: 'WRITE', + accepts: [{ + arg: 'to', + type: 'String', + required: true, + description: 'user (@) or channel (#) to send the message' + }, { + arg: 'message', + type: 'String', + required: true, + description: 'The message' + }], + returns: { + type: 'Object', + root: true + }, + http: { + path: `/sendMessage`, + verb: 'POST' + } + }); + + // FIXME: Deprecate this method #2019 + Self.sendMessage = async(ctx, to, message) => { + return Self.send(ctx, to, message); + }; +}; diff --git a/back/models/chat.js b/back/models/chat.js index ab23ef713..ecd47029c 100644 --- a/back/models/chat.js +++ b/back/models/chat.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/chat/send')(Self); + require('../methods/chat/sendMessage')(Self); require('../methods/chat/sendCheckingPresence')(Self); };