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

39 lines
694 B

import { Migrations } from '../../../app/migrations';
import { Subscriptions, Users } from '../../../app/models';
Migrations.add({
version: 133,
up() {
const subscriptions = Subscriptions.find({
t: 'd',
$or: [{
ts: { $gte: new Date('2018-07-09T00:00:00Z') },
}, {
ts: null,
}],
});
subscriptions.forEach((subscription) => {
if (subscription.name !== subscription.fname) {
return;
}
const user = Users.findOne({
username: subscription.name,
}, {
fields: {
name: 1,
},
});
if (!user) {
return;
}
Subscriptions.update({
_id: subscription._id,
}, {
$set: {
fname: user.name,
},
});
});
},
});