[MM-50734] Add option to use German HPNS notification proxy (#23562)
* Add option to use German HPNS notification proxy * Changes per feedback * make use of const * Fix privacy policy link * Fix bug found via https://github.com/mattermost/mattermost/pull/23562\#issuecomment-1581456269 --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
446b474489
Коммит
a6d1d38b27
@@ -19,6 +19,17 @@ const PUSH_NOTIFICATIONS_MHPNS = 'mhpns';
|
||||
const PUSH_NOTIFICATIONS_MTPNS = 'mtpns';
|
||||
const PUSH_NOTIFICATIONS_CUSTOM = 'custom';
|
||||
|
||||
const PUSH_NOTIFICATIONS_LOCATION_US = 'us';
|
||||
const PUSH_NOTIFICATIONS_LOCATION_DE = 'de';
|
||||
|
||||
const PUSH_NOTIFICATIONS_SERVER_DIC = {
|
||||
[PUSH_NOTIFICATIONS_LOCATION_US]: Constants.MHPNS_US,
|
||||
[PUSH_NOTIFICATIONS_LOCATION_DE]: Constants.MHPNS_DE,
|
||||
};
|
||||
|
||||
const DROPDOWN_ID_SERVER_TYPE = 'pushNotificationServerType';
|
||||
const DROPDOWN_ID_SERVER_LOCATION = 'pushNotificationServerLocation';
|
||||
|
||||
export default class PushSettings extends AdminSettings {
|
||||
canSave = () => {
|
||||
return this.state.pushNotificationServerType !== PUSH_NOTIFICATIONS_MHPNS || this.state.agree;
|
||||
@@ -31,14 +42,14 @@ export default class PushSettings extends AdminSettings {
|
||||
};
|
||||
|
||||
handleDropdownChange = (id, value) => {
|
||||
if (id === 'pushNotificationServerType') {
|
||||
if (id === DROPDOWN_ID_SERVER_TYPE) {
|
||||
this.setState({
|
||||
agree: false,
|
||||
});
|
||||
|
||||
if (value === PUSH_NOTIFICATIONS_MHPNS) {
|
||||
this.setState({
|
||||
pushNotificationServer: Constants.MHPNS,
|
||||
pushNotificationServer: PUSH_NOTIFICATIONS_SERVER_DIC[this.state.pushNotificationServerLocation],
|
||||
});
|
||||
} else if (value === PUSH_NOTIFICATIONS_MTPNS) {
|
||||
this.setState({
|
||||
@@ -53,6 +64,13 @@ export default class PushSettings extends AdminSettings {
|
||||
}
|
||||
}
|
||||
|
||||
if (id === DROPDOWN_ID_SERVER_LOCATION) {
|
||||
this.setState({
|
||||
pushNotificationServer: PUSH_NOTIFICATIONS_SERVER_DIC[value],
|
||||
pushNotificationServerLocation: value,
|
||||
});
|
||||
}
|
||||
|
||||
this.handleChange(id, value);
|
||||
};
|
||||
|
||||
@@ -67,11 +85,18 @@ export default class PushSettings extends AdminSettings {
|
||||
getStateFromConfig(config) {
|
||||
let pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM;
|
||||
let agree = false;
|
||||
let pushNotificationServerLocation = PUSH_NOTIFICATIONS_LOCATION_US;
|
||||
if (!config.EmailSettings.SendPushNotifications) {
|
||||
pushNotificationServerType = PUSH_NOTIFICATIONS_OFF;
|
||||
} else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS &&
|
||||
} else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS_US &&
|
||||
this.props.license.IsLicensed === 'true' && this.props.license.MHPNS === 'true') {
|
||||
pushNotificationServerType = PUSH_NOTIFICATIONS_MHPNS;
|
||||
pushNotificationServerLocation = PUSH_NOTIFICATIONS_LOCATION_US;
|
||||
agree = true;
|
||||
} else if (config.EmailSettings.PushNotificationServer === Constants.MHPNS_DE &&
|
||||
this.props.license.IsLicensed === 'true' && this.props.license.MHPNS === 'true') {
|
||||
pushNotificationServerType = PUSH_NOTIFICATIONS_MHPNS;
|
||||
pushNotificationServerLocation = PUSH_NOTIFICATIONS_LOCATION_DE;
|
||||
agree = true;
|
||||
} else if (config.EmailSettings.PushNotificationServer === Constants.MTPNS) {
|
||||
pushNotificationServerType = PUSH_NOTIFICATIONS_MTPNS;
|
||||
@@ -81,13 +106,14 @@ export default class PushSettings extends AdminSettings {
|
||||
if (pushNotificationServerType === PUSH_NOTIFICATIONS_MTPNS) {
|
||||
pushNotificationServer = Constants.MTPNS;
|
||||
} else if (pushNotificationServerType === PUSH_NOTIFICATIONS_MHPNS) {
|
||||
pushNotificationServer = Constants.MHPNS;
|
||||
pushNotificationServer = PUSH_NOTIFICATIONS_SERVER_DIC[pushNotificationServerLocation];
|
||||
}
|
||||
|
||||
const maxNotificationsPerChannel = config.TeamSettings.MaxNotificationsPerChannel;
|
||||
|
||||
return {
|
||||
pushNotificationServerType,
|
||||
pushNotificationServerLocation,
|
||||
pushNotificationServer,
|
||||
maxNotificationsPerChannel,
|
||||
agree,
|
||||
@@ -247,7 +273,7 @@ export default class PushSettings extends AdminSettings {
|
||||
{msg}
|
||||
</ExternalLink>
|
||||
),
|
||||
linkPricacy: (msg) => (
|
||||
linkPrivacy: (msg) => (
|
||||
<ExternalLink
|
||||
href='https://mattermost.com/data-processing-addendum/'
|
||||
location='push_settings'
|
||||
@@ -262,10 +288,35 @@ export default class PushSettings extends AdminSettings {
|
||||
);
|
||||
}
|
||||
|
||||
let locationDropdown;
|
||||
if (this.state.pushNotificationServerType === PUSH_NOTIFICATIONS_MHPNS) {
|
||||
const pushNotificationServerLocations = [
|
||||
{value: PUSH_NOTIFICATIONS_LOCATION_US, text: Utils.localizeMessage('admin.email.pushServerLocationUS', 'US')},
|
||||
{value: PUSH_NOTIFICATIONS_LOCATION_DE, text: Utils.localizeMessage('admin.email.pushServerLocationDE', 'Germany')},
|
||||
];
|
||||
|
||||
locationDropdown = (
|
||||
<DropdownSetting
|
||||
id={DROPDOWN_ID_SERVER_LOCATION}
|
||||
values={pushNotificationServerLocations}
|
||||
label={
|
||||
<FormattedMessage
|
||||
id='admin.email.pushServerLocationTitle'
|
||||
defaultMessage='Push Notification Server location:'
|
||||
/>
|
||||
}
|
||||
value={this.state.pushNotificationServerLocation}
|
||||
onChange={this.handleDropdownChange}
|
||||
setByEnv={this.isPushNotificationServerSetByEnv()}
|
||||
disabled={this.props.isDisabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingsGroup>
|
||||
<DropdownSetting
|
||||
id='pushNotificationServerType'
|
||||
id={DROPDOWN_ID_SERVER_TYPE}
|
||||
values={pushNotificationServerTypes}
|
||||
label={
|
||||
<FormattedMessage
|
||||
@@ -279,6 +330,7 @@ export default class PushSettings extends AdminSettings {
|
||||
setByEnv={this.isPushNotificationServerSetByEnv()}
|
||||
disabled={this.props.isDisabled}
|
||||
/>
|
||||
{locationDropdown}
|
||||
{tosCheckbox}
|
||||
<TextSetting
|
||||
id='pushNotificationServer'
|
||||
|
||||
@@ -808,6 +808,9 @@
|
||||
"admin.email.pushOff": "Do not send push notifications",
|
||||
"admin.email.pushOffHelp": "Please see <link>documentation on push notifications</link> to learn more about setup options.",
|
||||
"admin.email.pushServerEx": "E.g.: \"https://push-test.mattermost.com\"",
|
||||
"admin.email.pushServerLocationDE": "Germany",
|
||||
"admin.email.pushServerLocationTitle": "Push Notification Server location:",
|
||||
"admin.email.pushServerLocationUS": "US",
|
||||
"admin.email.pushServerTitle": "Push Notification Server:",
|
||||
"admin.email.pushTitle": "Enable Push Notifications: ",
|
||||
"admin.email.requireVerificationDescription": "Typically set to true in production. When true, Mattermost requires email verification after account creation prior to allowing login. Developers may set this field to false to skip sending verification emails for faster development.",
|
||||
|
||||
@@ -1936,7 +1936,8 @@ export const Constants = {
|
||||
EMOJI_PATH: '/static/emoji',
|
||||
RECENT_EMOJI_KEY: 'recentEmojis',
|
||||
DEFAULT_WEBHOOK_LOGO: logoWebhook,
|
||||
MHPNS: 'https://push.mattermost.com',
|
||||
MHPNS_US: 'https://push.mattermost.com',
|
||||
MHPNS_DE: 'https://hpns-de.mattermost.com',
|
||||
MTPNS: 'https://push-test.mattermost.com',
|
||||
MAX_PREV_MSGS: 100,
|
||||
POST_COLLAPSE_TIMEOUT: 1000 * 60 * 5, // five minutes
|
||||
|
||||
Ссылка в новой задаче
Block a user