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

54 lines
1.5 KiB

import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { Settings } from '../../../app/models/server';
import { Migrations } from '../../../app/migrations/server';
import { sendMessagesToAdmins } from '../../lib/sendMessagesToAdmins';
Migrations.add({
version: 201,
up: () => {
const pushEnabled = Settings.findOneById('Push_enable');
const pushGatewayEnabled = Settings.findOneById('Push_enable_gateway');
const registerServer = Settings.findOneById('Register_Server');
const cloudAgreement = Settings.findOneById('Cloud_Service_Agree_PrivacyTerms');
if (!pushEnabled?.value) {
return;
}
if (!pushGatewayEnabled?.value) {
return;
}
if (registerServer?.value && cloudAgreement?.value) {
return;
}
// if push gateway is enabled but server is not registered or cloud terms not agreed, disable gateway and alert admin
Settings.upsert({
_id: 'Push_enable_gateway',
}, {
$set: {
value: false,
},
});
const id = 'push-gateway-disabled';
const title = 'Action_required';
const text = 'The_mobile_notifications_were_disabled_to_all_users_go_to_Admin_Push_to_enable_the_Push_Gateway_again';
const link = '/admin/Push';
Meteor.startup(() => {
sendMessagesToAdmins({
msgs: ({ adminUser }) => [{ msg: `*${ TAPi18n.__(title, adminUser.language) }*\n${ TAPi18n.__(text, adminUser.language) }` }],
banners: [{
id,
priority: 100,
title,
text,
modifiers: ['danger'],
link,
}],
});
});
},
});