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