Code Improvement

pull/5629/head
Rodrigo Nascimento 9 years ago
parent b6b3a82f89
commit af946ee13a
No known key found for this signature in database
GPG Key ID: 2C85B3AFE75D23F9
  1. 18
      packages/rocketchat-integrations/server/processWebhookMessage.js

@ -25,16 +25,20 @@ function retrieveDirectMessageInfo({ currentUserId, channel, findByUserIdOnly=fa
}
const rid = _.isObject(roomUser) ? [currentUserId, roomUser._id].sort().join('') : channel;
const room = RocketChat.models.Rooms.findOneById(rid);
let room = RocketChat.models.Rooms.findOneById(rid);
if (_.isObject(room)) {
return room;
if (!_.isObject(room)) {
if (!_.isObject(roomUser)) {
throw new Meteor.Error('invalid-channel');
}
room = Meteor.runAsUser(currentUserId, function() {
const {rid} = Meteor.call('createDirectMessage', roomUser.username);
return RocketChat.models.Rooms.findOneById(rid);
});
}
return Meteor.runAsUser(currentUserId, function() {
const {rid} = Meteor.call('createDirectMessage', roomUser.username);
return RocketChat.models.Rooms.findOneById(rid);
});
return room;
}
this.processWebhookMessage = function(messageObj, user, defaultValues) {

Loading…
Cancel
Save