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

78 lines
1.6 KiB

RocketChat.Migrations.add({
version: 33,
up() {
const scriptAlert = '/**\n * This script is out-of-date, convert to the new format\n * (https://rocket.chat/docs/administrator-guides/integrations)\n**/\n\n';
const integrations = RocketChat.models.Integrations.find({
$or: [
{
script: {
$exists: false
},
processIncomingRequestScript: {
$exists: true
}
}, {
script: {
$exists: false
},
prepareOutgoingRequestScript: {
$exists: true
}
}, {
script: {
$exists: false
},
processOutgoingResponseScript: {
$exists: true
}
}
]
}).fetch();
integrations.forEach(function(integration) {
let script = '';
if (integration.processIncomingRequestScript) {
script += integration.processIncomingRequestScript + '\n\n';
}
if (integration.prepareOutgoingRequestScript) {
script += integration.prepareOutgoingRequestScript + '\n\n';
}
if (integration.processOutgoingResponseScript) {
script += integration.processOutgoingResponseScript + '\n\n';
}
return RocketChat.models.Integrations.update(integration._id, {
$set: {
script: scriptAlert + script.replace(/^/gm, '// ')
}
});
});
let update = {
$unset: {
processIncomingRequestScript: 1,
prepareOutgoingRequestScript: 1,
processOutgoingResponseScript: 1
}
};
RocketChat.models.Integrations.update({}, update, {
multi: true
});
update = {
$set: {
enabled: true
}
};
RocketChat.models.Integrations.update({
enabled: {
$exists: false
}
}, update, {
multi: true
});
}
});