The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/methods/loadMissedMessages.js

36 lines
775 B

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Messages } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
Meteor.methods({
loadMissedMessages(rid, start) {
check(rid, String);
check(start, Date);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'loadMissedMessages',
});
}
const fromId = Meteor.userId();
if (!Meteor.call('canAccessRoom', rid, fromId)) {
return false;
}
const options = {
sort: {
ts: -1,
},
};
if (!settings.get('Message_ShowEditedStatus')) {
options.fields = {
editedAt: 0,
};
}
return Messages.findVisibleByRoomIdAfterTimestamp(rid, start, options).fetch();
},
});