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/OEmbedCacheCleanup.js

22 lines
662 B

import { Meteor } from 'meteor/meteor';
import { OEmbedCache } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { hasRole } from 'meteor/rocketchat:authorization';
Meteor.methods({
OEmbedCacheCleanup() {
if (Meteor.userId() && !hasRole(Meteor.userId(), 'admin')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'OEmbedCacheCleanup',
});
}
const date = new Date();
const expirationDays = settings.get('API_EmbedCacheExpirationDays');
date.setDate(date.getDate() - expirationDays);
OEmbedCache.removeAfterDate(date);
return {
message: 'cache_cleared',
};
},
});