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/startup/migrations/v208.js

34 lines
599 B

import { addMigration } from '../../lib/migrations';
import { Users, Sessions } from '../../../app/models/server/raw';
async function migrateSessions() {
const cursor = Users.find({ roles: 'anonymous' }, { projection: { _id: 1 } });
if (!cursor) {
return;
}
const users = await cursor.toArray();
if (users.length === 0) {
return;
}
const userIds = users.map(({ _id }) => _id);
await Sessions.updateMany(
{
userId: { $in: userIds },
},
{
$set: {
roles: ['anonymous'],
},
},
);
}
addMigration({
version: 208,
up() {
Promise.await(migrateSessions());
},
});