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/packages/rocketchat-lib/server/methods/cleanRoomHistory.js

35 lines
759 B

Meteor.methods({
cleanRoomHistory({ roomId, latest, oldest, inclusive }) {
check(roomId, String);
check(latest, Date);
check(oldest, Date);
check(inclusive, Boolean);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'cleanRoomHistory' });
}
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'clean-channel-history')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'cleanRoomHistory' });
}
if (inclusive) {
RocketChat.models.Messages.remove({
rid: roomId,
ts: {
$gte: oldest,
$lte: latest
}
});
} else {
RocketChat.models.Messages.remove({
rid: roomId,
ts: {
$gt: oldest,
$lt: latest
}
});
}
}
});