Implement PR Comments
This commit is contained in:
1 parent
de3d38d891
commit
38a1d5e7a1
7 files changed
+96
-49
No files matched your search
@@ -26,6 +26,21 @@ const SettingsEmail = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
|
// Destructure settings with default values
|
||||||
|
const {
|
||||||
|
systemEmailHost = "",
|
||||||
|
systemEmailPort = "",
|
||||||
|
systemEmailSecure = false,
|
||||||
|
systemEmailPool = false,
|
||||||
|
systemEmailUser = "",
|
||||||
|
systemEmailAddress = "",
|
||||||
|
systemEmailPassword = "",
|
||||||
|
systemEmailTLSServername = "",
|
||||||
|
systemEmailConnectionHost = "localhost",
|
||||||
|
systemEmailIgnoreTLS = false,
|
||||||
|
systemEmailRequireTLS = false,
|
||||||
|
systemEmailRejectUnauthorized = true,
|
||||||
|
} = settingsData?.settings || {};
|
||||||
// Local state
|
// Local state
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [hasBeenReset, setHasBeenReset] = useState(false);
|
const [hasBeenReset, setHasBeenReset] = useState(false);
|
||||||
@@ -48,25 +63,31 @@ const SettingsEmail = ({
|
|||||||
const handleSendTestEmail = () => {
|
const handleSendTestEmail = () => {
|
||||||
// Collect current form values
|
// Collect current form values
|
||||||
const emailConfig = {
|
const emailConfig = {
|
||||||
systemEmailHost: settingsData?.settings?.systemEmailHost,
|
systemEmailHost,
|
||||||
systemEmailPort: settingsData?.settings?.systemEmailPort,
|
systemEmailPort,
|
||||||
systemEmailSecure: settingsData?.settings?.systemEmailSecure,
|
systemEmailSecure,
|
||||||
systemEmailPool: settingsData?.settings?.systemEmailPool,
|
systemEmailPool,
|
||||||
systemEmailUser: settingsData?.settings?.systemEmailUser,
|
systemEmailUser,
|
||||||
systemEmailAddress: settingsData?.settings?.systemEmailAddress,
|
systemEmailAddress,
|
||||||
systemEmailPassword: password || settingsData?.settings?.systemEmailPassword,
|
systemEmailPassword: password || systemEmailPassword,
|
||||||
systemEmailConnectionHost: settingsData?.settings?.systemEmailConnectionHost,
|
systemEmailTLSServername,
|
||||||
systemEmailTLSServername: settingsData?.settings?.systemEmailTLSServername,
|
systemEmailConnectionHost,
|
||||||
systemEmailIgnoreTLS: settingsData?.settings?.systemEmailIgnoreTLS,
|
systemEmailIgnoreTLS,
|
||||||
systemEmailRequireTLS: settingsData?.settings?.systemEmailRequireTLS,
|
systemEmailRequireTLS,
|
||||||
systemEmailRejectUnauthorized:
|
systemEmailRejectUnauthorized,
|
||||||
settingsData?.settings?.systemEmailRejectUnauthorized,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic validation
|
// Basic validation
|
||||||
if (!emailConfig.systemEmailHost || !emailConfig.systemEmailPort) {
|
if (
|
||||||
|
!emailConfig.systemEmailHost ||
|
||||||
|
!emailConfig.systemEmailPort ||
|
||||||
|
!emailConfig.systemEmailAddress
|
||||||
|
) {
|
||||||
createToast({
|
createToast({
|
||||||
body: t("settingsEmailRequiredFields", "Email host and port are required"),
|
body: t(
|
||||||
|
"settingsEmailRequiredFields",
|
||||||
|
"Email address, host and port are required"
|
||||||
|
),
|
||||||
variant: "error",
|
variant: "error",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -98,7 +119,7 @@ const SettingsEmail = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
name="systemEmailHost"
|
name="systemEmailHost"
|
||||||
placeholder="smtp.gmail.com"
|
placeholder="smtp.gmail.com"
|
||||||
value={settingsData?.settings?.systemEmailHost ?? ""}
|
value={systemEmailHost}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -108,7 +129,7 @@ const SettingsEmail = ({
|
|||||||
name="systemEmailPort"
|
name="systemEmailPort"
|
||||||
placeholder="425"
|
placeholder="425"
|
||||||
type="number"
|
type="number"
|
||||||
value={settingsData?.settings?.systemEmailPort ?? ""}
|
value={systemEmailPort}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -123,13 +144,13 @@ const SettingsEmail = ({
|
|||||||
<Typography>{t("settingsEmailSecure")}</Typography>
|
<Typography>{t("settingsEmailSecure")}</Typography>
|
||||||
<Switch
|
<Switch
|
||||||
name="systemEmailSecure"
|
name="systemEmailSecure"
|
||||||
checked={settingsData?.settings?.systemEmailSecure ?? false}
|
checked={systemEmailSecure}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<Typography>{t("settingsEmailPool")}</Typography>
|
<Typography>{t("settingsEmailPool")}</Typography>
|
||||||
<Switch
|
<Switch
|
||||||
name="systemEmailPool"
|
name="systemEmailPool"
|
||||||
checked={settingsData?.settings?.systemEmailPool ?? false}
|
checked={systemEmailPool}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -138,7 +159,7 @@ const SettingsEmail = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
name="systemEmailUser"
|
name="systemEmailUser"
|
||||||
placeholder="Leave empty if not required"
|
placeholder="Leave empty if not required"
|
||||||
value={settingsData?.settings?.systemEmailUser ?? ""}
|
value={systemEmailUser}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -147,7 +168,7 @@ const SettingsEmail = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
name="systemEmailAddress"
|
name="systemEmailAddress"
|
||||||
placeholder="uptime@bluewavelabs.ca"
|
placeholder="uptime@bluewavelabs.ca"
|
||||||
value={settingsData?.settings?.systemEmailAddress ?? ""}
|
value={systemEmailAddress}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -189,34 +210,33 @@ const SettingsEmail = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
name="systemEmailTLSServername"
|
name="systemEmailTLSServername"
|
||||||
placeholder="bluewavelabs.ca"
|
placeholder="bluewavelabs.ca"
|
||||||
value={settingsData?.settings?.systemEmailTLSServername ?? ""}
|
value={systemEmailTLSServername}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "row",
|
flexDirection: "column",
|
||||||
alignItems: "center",
|
|
||||||
gap: theme.spacing(4),
|
gap: theme.spacing(4),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography>{t("settingsEmailIgnoreTLS")}</Typography>
|
<Typography>{t("settingsEmailIgnoreTLS")}</Typography>
|
||||||
<Switch
|
<Switch
|
||||||
name="systemEmailIgnoreTLS"
|
name="systemEmailIgnoreTLS"
|
||||||
checked={settingsData?.settings?.systemEmailIgnoreTLS ?? false}
|
checked={systemEmailIgnoreTLS}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<Typography>{t("settingsEmailRequireTLS")}</Typography>
|
<Typography>{t("settingsEmailRequireTLS")}</Typography>
|
||||||
<Switch
|
<Switch
|
||||||
name="systemEmailRequireTLS"
|
name="systemEmailRequireTLS"
|
||||||
checked={settingsData?.settings?.systemEmailRequireTLS ?? false}
|
checked={systemEmailRequireTLS}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<Typography>{t("settingsEmailRejectUnauthorized")}</Typography>
|
<Typography>{t("settingsEmailRejectUnauthorized")}</Typography>
|
||||||
<Switch
|
<Switch
|
||||||
name="systemEmailRejectUnauthorized"
|
name="systemEmailRejectUnauthorized"
|
||||||
checked={settingsData?.settings?.systemEmailRejectUnauthorized ?? false}
|
checked={systemEmailRejectUnauthorized}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -225,7 +245,7 @@ const SettingsEmail = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
name="systemEmailConnectionHost"
|
name="systemEmailConnectionHost"
|
||||||
placeholder="bluewavelabs.ca"
|
placeholder="bluewavelabs.ca"
|
||||||
value={settingsData?.settings?.systemEmailConnectionHost ?? ""}
|
value={systemEmailConnectionHost}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1020,10 +1020,6 @@ class NetworkService {
|
|||||||
systemEmailRequireTLS: emailConfig.systemEmailRequireTLS,
|
systemEmailRequireTLS: emailConfig.systemEmailRequireTLS,
|
||||||
systemEmailRejectUnauthorized: emailConfig.systemEmailRejectUnauthorized,
|
systemEmailRejectUnauthorized: emailConfig.systemEmailRejectUnauthorized,
|
||||||
systemEmailTLSServername: emailConfig.systemEmailTLSServername,
|
systemEmailTLSServername: emailConfig.systemEmailTLSServername,
|
||||||
// Only include these if they are present
|
|
||||||
...(emailConfig.systemEmailConnectionHost && {
|
|
||||||
systemEmailConnectionHost: emailConfig.systemEmailConnectionHost,
|
|
||||||
}),
|
|
||||||
...(emailConfig.systemEmailUser && {
|
...(emailConfig.systemEmailUser && {
|
||||||
systemEmailUser: emailConfig.systemEmailUser,
|
systemEmailUser: emailConfig.systemEmailUser,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -295,11 +295,11 @@ const settingsValidation = joi.object({
|
|||||||
systemEmailAddress: joi.string().allow(""),
|
systemEmailAddress: joi.string().allow(""),
|
||||||
systemEmailPassword: joi.string().allow(""),
|
systemEmailPassword: joi.string().allow(""),
|
||||||
systemEmailUser: joi.string().allow(""),
|
systemEmailUser: joi.string().allow(""),
|
||||||
systemEmailConnectionHost: joi.string().allow(""),
|
systemEmailConnectionHost: joi.string().allow("").optional(),
|
||||||
systemEmailTLSServername: joi.string().allow(""),
|
systemEmailTLSServername: joi.string().allow(""),
|
||||||
systemEmailIgnoreTLS: joi.boolean().optional(),
|
systemEmailIgnoreTLS: joi.boolean(),
|
||||||
systemEmailRequireTLS: joi.boolean().optional(),
|
systemEmailRequireTLS: joi.boolean(),
|
||||||
systemEmailRejectUnauthorized: joi.boolean().optional(),
|
systemEmailRejectUnauthorized: joi.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const dayjsValidator = (value, helpers) => {
|
const dayjsValidator = (value, helpers) => {
|
||||||
|
|||||||
@@ -673,17 +673,17 @@
|
|||||||
},
|
},
|
||||||
"settingsEmail": "Email",
|
"settingsEmail": "Email",
|
||||||
"settingsEmailDescription": "Configure the email settings for your system. This is used to send notifications and alerts.",
|
"settingsEmailDescription": "Configure the email settings for your system. This is used to send notifications and alerts.",
|
||||||
"settingsEmailHost": "Email host - Hostname or IP address of the SMTP server",
|
"settingsEmailHost": "Email host - Hostname or IP address to connect to",
|
||||||
"settingsEmailPort": "Email port - Port to connect to",
|
"settingsEmailPort": "Email port - Port to connect to",
|
||||||
"settingsEmailAddress": "Email address - Used for authentication",
|
"settingsEmailAddress": "Email address - Used for authentication",
|
||||||
"settingsEmailPassword": "Email password - Password for authentication",
|
"settingsEmailPassword": "Email password - Password for authentication",
|
||||||
"settingsEmailUser": "Email user - Username for authentication, overrides email address if specified",
|
"settingsEmailUser": "Email user - Username for authentication, overrides email address if specified",
|
||||||
"settingsEmailFieldResetLabel": "Password is set. Click Reset to change it.",
|
"settingsEmailFieldResetLabel": "Password is set. Click Reset to change it.",
|
||||||
"settingsEmailTLSServername": "TLS Servername - Optional Hostname for TLS Validation when host is an IP",
|
"settingsEmailTLSServername": "TLS Servername - Optional Hostname for TLS Validation when host is an IP",
|
||||||
"settingsEmailIgnoreTLS": "Ignore TLS",
|
"settingsEmailIgnoreTLS": "Ignore TLS - Disable STARTTLS",
|
||||||
"settingsEmailRequireTLS": "Require TLS",
|
"settingsEmailRequireTLS": "Require TLS - Force STARTTLS",
|
||||||
"settingsEmailRejectUnauthorized": "Reject Unauthorized",
|
"settingsEmailRejectUnauthorized": "Reject Unauthorized",
|
||||||
"settingsEmailSecure": "Secure",
|
"settingsEmailSecure": "Secure - Use SSL",
|
||||||
"settingsEmailPool": "Pool",
|
"settingsEmailPool": "Pool",
|
||||||
"state": "State",
|
"state": "State",
|
||||||
"statusBreadCrumbsStatusPages": "Status Pages",
|
"statusBreadCrumbsStatusPages": "Status Pages",
|
||||||
@@ -714,7 +714,7 @@
|
|||||||
"settingsTestEmailFailed": "Failed to send test email",
|
"settingsTestEmailFailed": "Failed to send test email",
|
||||||
"settingsTestEmailFailedWithReason": "Failed to send test email: {{reason}}",
|
"settingsTestEmailFailedWithReason": "Failed to send test email: {{reason}}",
|
||||||
"settingsTestEmailUnknownError": "Unknown error",
|
"settingsTestEmailUnknownError": "Unknown error",
|
||||||
"settingsEmailRequiredFields": "Email host and port are required",
|
"settingsEmailRequiredFields": "Email address, host and port are required",
|
||||||
"statusMsg": {
|
"statusMsg": {
|
||||||
"paused": "Monitoring is paused.",
|
"paused": "Monitoring is paused.",
|
||||||
"up": "Your site is up.",
|
"up": "Your site is up.",
|
||||||
|
|||||||
@@ -32,6 +32,29 @@ const AppSettingsSchema = mongoose.Schema(
|
|||||||
type: String,
|
type: String,
|
||||||
default: "localhost",
|
default: "localhost",
|
||||||
},
|
},
|
||||||
|
systemEmailTLSServername: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
systemEmailSecure: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
systemEmailPool: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
systemEmailIgnoreTLS: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
systemEmailRequireTLS: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
systemEmailRejectUnauthorized: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
singleton: {
|
singleton: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
@@ -121,13 +121,15 @@ class EmailService {
|
|||||||
user: systemEmailUser || systemEmailAddress,
|
user: systemEmailUser || systemEmailAddress,
|
||||||
pass: systemEmailPassword,
|
pass: systemEmailPassword,
|
||||||
},
|
},
|
||||||
|
name: systemEmailConnectionHost || "localhost",
|
||||||
connectionTimeout: 5000,
|
connectionTimeout: 5000,
|
||||||
pool: systemEmailPool,
|
pool: systemEmailPool,
|
||||||
tls: { rejectUnauthorized: systemEmailRejectUnauthorized },
|
tls: {
|
||||||
ignoreTLS: systemEmailIgnoreTLS,
|
rejectUnauthorized: systemEmailRejectUnauthorized,
|
||||||
requireTLS: systemEmailRequireTLS,
|
ignoreTLS: systemEmailIgnoreTLS,
|
||||||
servername: systemEmailTLSServername,
|
requireTLS: systemEmailRequireTLS,
|
||||||
name: systemEmailConnectionHost || "localhost",
|
servername: systemEmailTLSServername,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
this.transporter = this.nodemailer.createTransport(emailConfig);
|
this.transporter = this.nodemailer.createTransport(emailConfig);
|
||||||
|
|||||||
@@ -413,7 +413,13 @@ const updateAppSettingsBodyValidation = joi.object({
|
|||||||
systemEmailAddress: joi.string().allow(""),
|
systemEmailAddress: joi.string().allow(""),
|
||||||
systemEmailPassword: joi.string().allow(""),
|
systemEmailPassword: joi.string().allow(""),
|
||||||
systemEmailUser: joi.string().allow(""),
|
systemEmailUser: joi.string().allow(""),
|
||||||
systemEmailConnectionHost: joi.string().allow(""),
|
systemEmailConnectionHost: joi.string().allow("").optional(),
|
||||||
|
systemEmailTLSServername: joi.string().allow("").optional(),
|
||||||
|
systemEmailSecure: joi.boolean(),
|
||||||
|
systemEmailPool: joi.boolean(),
|
||||||
|
systemEmailIgnoreTLS: joi.boolean(),
|
||||||
|
systemEmailRequireTLS: joi.boolean(),
|
||||||
|
systemEmailRejectUnauthorized: joi.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
@@ -622,11 +628,11 @@ const sendTestEmailBodyValidation = joi.object({
|
|||||||
systemEmailAddress: joi.string(),
|
systemEmailAddress: joi.string(),
|
||||||
systemEmailPassword: joi.string(),
|
systemEmailPassword: joi.string(),
|
||||||
systemEmailUser: joi.string(),
|
systemEmailUser: joi.string(),
|
||||||
systemEmailConnectionHost: joi.string(),
|
systemEmailConnectionHost: joi.string().allow("").optional(),
|
||||||
systemEmailIgnoreTLS: joi.boolean(),
|
systemEmailIgnoreTLS: joi.boolean(),
|
||||||
systemEmailRequireTLS: joi.boolean(),
|
systemEmailRequireTLS: joi.boolean(),
|
||||||
systemEmailRejectUnauthorized: joi.boolean(),
|
systemEmailRejectUnauthorized: joi.boolean(),
|
||||||
systemEmailTLSServername: joi.string(),
|
systemEmailTLSServername: joi.string().allow("").optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
Reference in new issue
Block a user