adding chat.react API EndPoint

pull/9487/head
Joaquin GT 8 years ago
parent 48ad1ef484
commit db3ee514da
  1. 20
      packages/rocketchat-api/server/v1/chat.js
  2. 4
      packages/rocketchat-reactions/client/methods/setReaction.js

@ -255,3 +255,23 @@ RocketChat.API.v1.addRoute('chat.update', { authRequired: true }, {
});
}
});
RocketChat.API.v1.addRoute('chat.react', { authRequired: true }, {
post() {
if (!this.bodyParams.messageId || !this.bodyParams.messageId.trim()) {
throw new Meteor.Error('error-messageid-param-not-provided', 'The required "messageId" param is missing.');
}
const msg = RocketChat.models.Messages.findOneById(this.bodyParams.messageId);
if (!msg) {
throw new Meteor.Error('error-message-not-found', 'The provided "messageId" does not match any existing message.');
}
const emoji = this.bodyParams.emoji;
Meteor.runAsUser(this.userId, () => Meteor.call('setReaction', emoji, msg._id, this.userId));
return RocketChat.API.v1.success();
}
});

@ -1,12 +1,12 @@
import _ from 'underscore';
Meteor.methods({
setReaction(reaction, messageId) {
setReaction(reaction, messageId, usr) {
if (!Meteor.userId()) {
throw new Meteor.Error(203, 'User_logged_out');
}
const user = Meteor.user();
const user = usr ? usr : Meteor.user();
const message = RocketChat.models.Messages.findOne({ _id: messageId });
const room = RocketChat.models.Rooms.findOne({ _id: message.rid });

Loading…
Cancel
Save