[FIX] Push gateway and cloud integration (#18377)
* Link push gateway setting to cloud register * Add migration to disable gateway and alert adminspull/18383/head
parent
cf053273f6
commit
dfeebb8afc
@ -0,0 +1,54 @@ |
|||||||
|
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, |
||||||
|
}], |
||||||
|
}); |
||||||
|
}); |
||||||
|
}, |
||||||
|
}); |
Loading…
Reference in new issue