Skip to content
Snippets Groups Projects
Unverified Commit b6b3a82f authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Code improvement

parent 918e31ea
No related branches found
No related tags found
No related merge requests found
......@@ -24,23 +24,17 @@ function retrieveDirectMessageInfo({ currentUserId, channel, findByUserIdOnly=fa
});
}
let room, rid;
if (_.isObject(roomUser)) {
rid = [currentUserId, roomUser._id].sort().join('');
room = RocketChat.models.Rooms.findOneById(rid);
} else {
room = RocketChat.models.Rooms.findOneById(channel);
}
const rid = _.isObject(roomUser) ? [currentUserId, roomUser._id].sort().join('') : channel;
const room = RocketChat.models.Rooms.findOneById(rid);
if (_.isObject(room)) {
return room;
}
Meteor.runAsUser(currentUserId, function() {
rid = Meteor.call('createDirectMessage', roomUser.username).rid;
return Meteor.runAsUser(currentUserId, function() {
const {rid} = Meteor.call('createDirectMessage', roomUser.username);
return RocketChat.models.Rooms.findOneById(rid);
});
return RocketChat.models.Rooms.findOneById(rid);
}
this.processWebhookMessage = function(messageObj, user, defaultValues) {
......
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