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

37 lines
688 B

import _ from 'underscore';
import { OEmbed } from '../../../app/oembed/server';
import { Migrations } from '../../../app/migrations';
import { Messages } from '../../../app/models';
Migrations.add({
version: 7,
up() {
console.log('Populate urls in messages');
const query = Messages.find({
'urls.0': {
$exists: true,
},
});
const count = query.count();
query.forEach((message, index) => {
console.log(`${ index + 1 } / ${ count }`);
message.urls = message.urls.map((url) => {
if (_.isString(url)) {
return {
url,
};
}
return url;
});
return OEmbed.rocketUrlParser(message);
});
return console.log('End');
},
});