Rocketchat lib2#6593
Conversation
| }); | ||
| } | ||
| const cursor = RocketChat.models[model][method].apply(RocketChat.models[model], args); | ||
| return cursor && cursor.fetch && cursor.fetch(); |
There was a problem hiding this comment.
This will return undefined when calling a findOne.
The called method could return a object or undefined from a findOne result or a cursor from a find result.
So the cursor can be an object from a record or an object from a cursor or undefined.
If the result is and cursor, that is ok, the fetch is the desired method to execute to get the data.
If the result is and object from a findOne you will return a property called fetch as undefined or will throw and error trying to execute the property as a function.
Take a look at the old code and try to use the same logic here
| let msgTs; | ||
| let currentTsDiff; | ||
| const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes'); | ||
| if ((blockDeleteInMinutes != null) && blockDeleteInMinutes !== 0) { |
There was a problem hiding this comment.
No need for this extra parenthesis
| msgTs = moment(originalMessage.ts); | ||
| } | ||
| if (msgTs != null) { | ||
| currentTsDiff = moment().diff(msgTs, 'minutes'); |
There was a problem hiding this comment.
Use can use const for msgTs and currentTsDiff and put the ifs chained
|
@rodrigok , it's done. |
@RocketChat/core