-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rocketchat lib2 #6593
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use can use const
for msgTs
and currentTsDiff
and put the ifs chained
@rodrigok , it's done. |
@RocketChat/core