[MM-54594] Adding new global relay type (#24672)

* adding new global relay type, custom
Этот коммит содержится в:
Ben Cooke
2023-12-07 16:39:10 -05:00
коммит произвёл GitHub
родитель 769c7da7c5
Коммит a11b27d1f2
8 изменённых файлов: 108 добавлений и 7 удалений

Просмотреть файл

@@ -630,6 +630,8 @@ const defaultServerConfig: AdminConfig = {
SMTPPassword: '',
EmailAddress: '',
SMTPServerTimeout: 1800,
CustomSMTPServerName: '',
CustomSMTPPort: '25',
},
},
JobSettings: {

Просмотреть файл

@@ -8848,7 +8848,11 @@
},
{
"id": "model.config.is_valid.message_export.global_relay.customer_type.app_error",
"translation": "Message export GlobalRelaySettings.CustomerType must be set to one of either 'A9' or 'A10'."
"translation": "Message export GlobalRelaySettings.CustomerType must be set to one of either 'A9', 'A10' or 'CUSTOM."
},
{
"id": "model.config.is_valid.message_export.global_relay.customer_type_custom.app_error",
"translation": "If GlobalRelaySettings.CustomerType is 'CUSTOM', then GlobalRelaySettings.CustomSMTPServerName and GlobalRelaySettings.CustomSMTPPort must be set."
},
{
"id": "model.config.is_valid.message_export.global_relay.email_address.app_error",

Просмотреть файл

@@ -226,6 +226,7 @@ const (
ComplianceExportTypeGlobalrelayZip = "globalrelay-zip"
GlobalrelayCustomerTypeA9 = "A9"
GlobalrelayCustomerTypeA10 = "A10"
GlobalrelayCustomerTypeCustom = "CUSTOM"
ClientSideCertCheckPrimaryAuth = "primary"
ClientSideCertCheckSecondaryAuth = "secondary"
@@ -3108,11 +3109,13 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
}
type GlobalRelayMessageExportSettings struct {
CustomerType *string `access:"compliance_compliance_export"` // must be either A9 or A10, dictates SMTP server url
SMTPUsername *string `access:"compliance_compliance_export"`
SMTPPassword *string `access:"compliance_compliance_export"`
EmailAddress *string `access:"compliance_compliance_export"` // the address to send messages to
SMTPServerTimeout *int `access:"compliance_compliance_export"`
CustomerType *string `access:"compliance_compliance_export"` // must be either A9, A10 or CUSTOM, dictates SMTP server url
SMTPUsername *string `access:"compliance_compliance_export"`
SMTPPassword *string `access:"compliance_compliance_export"`
EmailAddress *string `access:"compliance_compliance_export"` // the address to send messages to
SMTPServerTimeout *int `access:"compliance_compliance_export"`
CustomSMTPServerName *string `access:"compliance_compliance_export"`
CustomSMTPPort *string `access:"compliance_compliance_export"`
}
func (s *GlobalRelayMessageExportSettings) SetDefaults() {
@@ -3131,6 +3134,12 @@ func (s *GlobalRelayMessageExportSettings) SetDefaults() {
if s.SMTPServerTimeout == nil || *s.SMTPServerTimeout == 0 {
s.SMTPServerTimeout = NewInt(1800)
}
if s.CustomSMTPServerName == nil {
s.CustomSMTPServerName = NewString("")
}
if s.CustomSMTPPort == nil {
s.CustomSMTPPort = NewString("25")
}
}
type MessageExportSettings struct {
@@ -4105,8 +4114,10 @@ func (s *MessageExportSettings) isValid() *AppError {
if *s.ExportFormat == ComplianceExportTypeGlobalrelay {
if s.GlobalRelaySettings == nil {
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.config_missing.app_error", nil, "", http.StatusBadRequest)
} else if s.GlobalRelaySettings.CustomerType == nil || (*s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeA9 && *s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeA10) {
} else if s.GlobalRelaySettings.CustomerType == nil || (*s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeA9 && *s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeA10 && *s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeCustom) {
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.customer_type.app_error", nil, "", http.StatusBadRequest)
} else if *s.GlobalRelaySettings.CustomerType == GlobalrelayCustomerTypeCustom && ((s.GlobalRelaySettings.CustomSMTPServerName == nil || *s.GlobalRelaySettings.CustomSMTPServerName == "") || (s.GlobalRelaySettings.CustomSMTPPort == nil || *s.GlobalRelaySettings.CustomSMTPPort == "")) {
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.customer_type_custom.app_error", nil, "", http.StatusBadRequest)
} else if s.GlobalRelaySettings.EmailAddress == nil || !strings.Contains(*s.GlobalRelaySettings.EmailAddress, "@") {
// validating email addresses is hard - just make sure it contains an '@' sign
// see https://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address

Просмотреть файл

@@ -316,6 +316,10 @@ exports[`components/MessageExportSettings should match snapshot, disabled, globa
"text": "A10/Type 10",
"value": "A10",
},
Object {
"text": "Custom",
"value": "CUSTOM",
},
]
}
/>
@@ -757,6 +761,10 @@ exports[`components/MessageExportSettings should match snapshot, enabled, global
"text": "A10/Type 10",
"value": "A10",
},
Object {
"text": "Custom",
"value": "CUSTOM",
},
]
}
/>

Просмотреть файл

@@ -82,6 +82,8 @@ describe('components/MessageExportSettings', () => {
SMTPUsername: 'globalRelayUser',
SMTPPassword: 'globalRelayPassword',
EmailAddress: 'globalRelay@mattermost.com',
CustomSMTPServerName: '',
CustomSMTPPort: '25',
},
},
};
@@ -126,6 +128,8 @@ describe('components/MessageExportSettings', () => {
SMTPUsername: 'globalRelayUser',
SMTPPassword: 'globalRelayPassword',
EmailAddress: 'globalRelay@mattermost.com',
CustomSMTPServerName: '',
CustomSMTPPort: '25',
},
},
};

Просмотреть файл

@@ -32,6 +32,8 @@ interface State extends BaseState {
globalRelaySMTPUsername: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['SMTPUsername'];
globalRelaySMTPPassword: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['SMTPPassword'];
globalRelayEmailAddress: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['EmailAddress'];
globalRelayCustomSMTPServerName: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['CustomSMTPServerName'];
globalRelayCustomSMTPPort: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['CustomSMTPPort'];
globalRelaySMTPServerTimeout: AdminConfig['MessageExportSettings']['GlobalRelaySettings']['SMTPServerTimeout'];
}
@@ -47,6 +49,8 @@ export default class MessageExportSettings extends AdminSettings<BaseProps, Stat
SMTPUsername: this.state.globalRelaySMTPUsername,
SMTPPassword: this.state.globalRelaySMTPPassword,
EmailAddress: this.state.globalRelayEmailAddress,
CustomSMTPServerName: this.state.globalRelayCustomSMTPServerName,
CustomSMTPPort: this.state.globalRelayCustomSMTPPort,
SMTPServerTimeout: this.state.globalRelaySMTPServerTimeout,
};
}
@@ -63,6 +67,8 @@ export default class MessageExportSettings extends AdminSettings<BaseProps, Stat
globalRelaySMTPPassword: '',
globalRelayEmailAddress: '',
globalRelaySMTPServerTimeout: 0,
globalRelayCustomSMTPServerName: '',
globalRelayCustomSMTPPort: '',
saveNeeded: false,
saving: false,
serverError: null,
@@ -73,6 +79,8 @@ export default class MessageExportSettings extends AdminSettings<BaseProps, Stat
state.globalRelaySMTPUsername = config.MessageExportSettings.GlobalRelaySettings.SMTPUsername;
state.globalRelaySMTPPassword = config.MessageExportSettings.GlobalRelaySettings.SMTPPassword;
state.globalRelayEmailAddress = config.MessageExportSettings.GlobalRelaySettings.EmailAddress;
state.globalRelayCustomSMTPServerName = config.MessageExportSettings.GlobalRelaySettings.CustomSMTPServerName;
state.globalRelayCustomSMTPPort = config.MessageExportSettings.GlobalRelaySettings.CustomSMTPPort;
}
return state;
}
@@ -148,6 +156,7 @@ export default class MessageExportSettings extends AdminSettings<BaseProps, Stat
values={[
{value: 'A9', text: Utils.localizeMessage('admin.complianceExport.globalRelayCustomerType.a9.description', 'A9/Type 9')},
{value: 'A10', text: Utils.localizeMessage('admin.complianceExport.globalRelayCustomerType.a10.description', 'A10/Type 10')},
{value: 'CUSTOM', text: Utils.localizeMessage('admin.complianceExport.globalRelayCustomerType.custom.description', 'Custom')},
]}
label={
<FormattedMessage
@@ -237,12 +246,66 @@ export default class MessageExportSettings extends AdminSettings<BaseProps, Stat
/>
);
const globalRelaySMTPServerName = (
<TextSetting
id='globalRelayCustomSMTPServerName'
label={
<FormattedMessage
id='admin.complianceExport.globalRelayCustomSMTPServerName.title'
defaultMessage='SMTP Server Name:'
/>
}
placeholder={Utils.localizeMessage('admin.complianceExport.globalRelayCustomSMTPServerName.example', 'E.g.: "feeds.globalrelay.com"')}
helpText={
<FormattedMessage
id='admin.complianceExport.globalRelayCustomSMTPServerName.description'
defaultMessage='The SMTP server name that will receive your Global Relay EML.'
/>
}
value={this.state.globalRelayCustomSMTPServerName ? this.state.globalRelayCustomSMTPServerName : ''}
onChange={this.handleChange}
setByEnv={this.isSetByEnv('DataRetentionSettings.GlobalRelaySettings.CustomSMTPServerName')}
disabled={this.props.isDisabled || !this.state.enableComplianceExport}
/>
);
const globalRelaySMTPPort = (
<TextSetting
id='globalRelayCustomSMTPPort'
label={
<FormattedMessage
id='admin.complianceExport.globalRelayCustomSMTPPort.title'
defaultMessage='SMTP Server Port:'
/>
}
placeholder={Utils.localizeMessage('admin.complianceExport.globalRelayCustomSMTPPort.example', 'E.g.: "25"')}
helpText={
<FormattedMessage
id='admin.complianceExport.globalRelayCustomSMTPPort.description'
defaultMessage='The SMTP server port that will receive your Global Relay EML.'
/>
}
value={this.state.globalRelayCustomSMTPPort ? this.state.globalRelayCustomSMTPPort : ''}
onChange={this.handleChange}
setByEnv={this.isSetByEnv('DataRetentionSettings.GlobalRelaySettings.CustomSMTPPort')}
disabled={this.props.isDisabled || !this.state.enableComplianceExport}
/>
);
globalRelaySettings = (
<SettingsGroup id={'globalRelaySettings'} >
{globalRelayCustomerType}
{globalRelaySMTPUsername}
{globalRelaySMTPPassword}
{globalRelayEmail}
{
this.state.globalRelayCustomerType === 'CUSTOM' &&
globalRelaySMTPServerName
}
{
this.state.globalRelayCustomerType === 'CUSTOM' &&
globalRelaySMTPPort
}
</SettingsGroup>
);
}

Просмотреть файл

@@ -607,8 +607,15 @@
"admin.complianceExport.exportJobStartTime.title": "Compliance Export time:",
"admin.complianceExport.globalRelayCustomerType.a10.description": "A10/Type 10",
"admin.complianceExport.globalRelayCustomerType.a9.description": "A9/Type 9",
"admin.complianceExport.globalRelayCustomerType.custom.description": "Custom",
"admin.complianceExport.globalRelayCustomerType.description": "Type of Global Relay customer account your organization has.",
"admin.complianceExport.globalRelayCustomerType.title": "Global Relay Customer Account:",
"admin.complianceExport.globalRelayCustomSMTPPort.description": "The SMTP server port that will receive your Global Relay EML.",
"admin.complianceExport.globalRelayCustomSMTPPort.example": "E.g.: \"25\"",
"admin.complianceExport.globalRelayCustomSMTPPort.title": "SMTP Server Port:",
"admin.complianceExport.globalRelayCustomSMTPServerName.description": "The SMTP server name that will receive your Global Relay EML.",
"admin.complianceExport.globalRelayCustomSMTPServerName.example": "E.g.: \"feeds.globalrelay.com\"",
"admin.complianceExport.globalRelayCustomSMTPServerName.title": "SMTP Server Name:",
"admin.complianceExport.globalRelayEmailAddress.description": "The email address your Global Relay server monitors for incoming compliance exports.",
"admin.complianceExport.globalRelayEmailAddress.example": "E.g.: \"globalrelay@mattermost.com\"",
"admin.complianceExport.globalRelayEmailAddress.title": "Global Relay Email Address:",

Просмотреть файл

@@ -833,6 +833,8 @@ export type MessageExportSettings = {
SMTPPassword: string;
EmailAddress: string;
SMTPServerTimeout: number;
CustomSMTPServerName: string;
CustomSMTPPort: string;
};
};