Merge pull request #13 from Myzel394/add-image-proxy-option

feat: Add enable_image_proxy_storage option to GlobalSettings
This commit is contained in:
Myzel394 2023-02-24 15:01:51 +01:00 committed by GitHub
commit c72db4f54c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 26 deletions

View File

@ -379,6 +379,10 @@
}, },
"enableImageProxy": { "enableImageProxy": {
"label": "Enable image proxy", "label": "Enable image proxy",
"description": "If enabled, images will be proxied through the server. This enhances your user's privacy as their ip address will not be leaked."
},
"enableImageProxyStorage": {
"label": "Enable image proxy storage",
"description": "If enabled, images will be stored on the server and forwarded to the user. This makes email tracking nearly impossible as every message will be marked as read instantly, which is obviously not true as a user is typically not able to view an email in just a few seconds after it has been sent. This will only affect new images." "description": "If enabled, images will be stored on the server and forwarded to the user. This makes email tracking nearly impossible as every message will be marked as read instantly, which is obviously not true as a user is typically not able to view an email in just a few seconds after it has been sent. This will only affect new images."
}, },
"userEmailEnableDisposableEmails": { "userEmailEnableDisposableEmails": {

View File

@ -10,6 +10,7 @@ export const DEFAULT_ADMIN_SETTINGS: AdminSettings = {
userEmailEnableDisposableEmails: false, userEmailEnableDisposableEmails: false,
imageProxyStorageLifeTimeInHours: 24, imageProxyStorageLifeTimeInHours: 24,
enableImageProxy: true, enableImageProxy: true,
enableImageProxyStorage: true,
allowStatistics: true, allowStatistics: true,
allowAliasDeletion: false, allowAliasDeletion: false,
maxAliasesPerUser: 0, maxAliasesPerUser: 0,

View File

@ -11,6 +11,7 @@ import AliasesPercentageAmount from "./AliasPercentageAmount"
import { import {
Checkbox, Checkbox,
Collapse,
FormControlLabel, FormControlLabel,
FormGroup, FormGroup,
FormHelperText, FormHelperText,
@ -82,6 +83,9 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
enableImageProxy: yup enableImageProxy: yup
.boolean() .boolean()
.label(t("routes.AdminRoute.forms.settings.enableImageProxy.label")), .label(t("routes.AdminRoute.forms.settings.enableImageProxy.label")),
enableImageProxyStorage: yup
.boolean()
.label(t("routes.AdminRoute.forms.settings.enableImageProxyStorage.label")),
allowStatistics: yup allowStatistics: yup
.boolean() .boolean()
.label(t("routes.AdminRoute.forms.settings.allowStatistics.label")), .label(t("routes.AdminRoute.forms.settings.allowStatistics.label")),
@ -465,33 +469,70 @@ export default function SettingsForm({settings, queryKey}: SettingsFormProps) {
</FormGroup> </FormGroup>
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
<FormGroup key="enable_image_proxy"> <Grid container spacing={1}>
<FormControlLabel <Grid item>
control={ <FormGroup key="enable_image_proxy">
<Checkbox <FormControlLabel
checked={formik.values.enableImageProxy} control={
onChange={formik.handleChange} <Checkbox
name="enableImageProxy" checked={formik.values.enableImageProxy}
onChange={formik.handleChange}
name="enableImageProxy"
/>
}
disabled={formik.isSubmitting}
label={t(
"routes.AdminRoute.forms.settings.enableImageProxy.label",
)}
/> />
} <FormHelperText
disabled={formik.isSubmitting} error={
label={t( formik.touched.enableImageProxy &&
"routes.AdminRoute.forms.settings.enableImageProxy.label", Boolean(formik.errors.enableImageProxy)
)} }
/> >
<FormHelperText {(formik.touched.enableImageProxy &&
error={ formik.errors.enableImageProxy) ||
formik.touched.enableImageProxy && t(
Boolean(formik.errors.enableImageProxy) "routes.AdminRoute.forms.settings.enableImageProxy.description",
} )}
> </FormHelperText>
{(formik.touched.enableImageProxy && </FormGroup>
formik.errors.enableImageProxy) || </Grid>
t( <Grid item>
"routes.AdminRoute.forms.settings.enableImageProxy.description", <Collapse in={formik.values.enableImageProxy}>
)} <FormGroup key="enable_image_proxy_storage">
</FormHelperText> <FormControlLabel
</FormGroup> control={
<Checkbox
checked={
formik.values.enableImageProxyStorage
}
onChange={formik.handleChange}
name="enableImageProxyStorage"
/>
}
disabled={formik.isSubmitting}
label={t(
"routes.AdminRoute.forms.settings.enableImageProxyStorage.label",
)}
/>
<FormHelperText
error={
formik.touched.enableImageProxyStorage &&
Boolean(formik.errors.enableImageProxyStorage)
}
>
{(formik.touched.enableImageProxyStorage &&
formik.errors.enableImageProxyStorage) ||
t(
"routes.AdminRoute.forms.settings.enableImageProxyStorage.description",
)}
</FormHelperText>
</FormGroup>
</Collapse>
</Grid>
</Grid>
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
<FormGroup key="allow_statistics"> <FormGroup key="allow_statistics">

View File

@ -208,6 +208,7 @@ export interface AdminSettings {
customEmailSuffixChars: string customEmailSuffixChars: string
imageProxyStorageLifeTimeInHours: number imageProxyStorageLifeTimeInHours: number
enableImageProxy: boolean enableImageProxy: boolean
enableImageProxyStorage: boolean
userEmailEnableDisposableEmails: boolean userEmailEnableDisposableEmails: boolean
userEmailEnableOtherRelays: boolean userEmailEnableOtherRelays: boolean
allowStatistics: boolean allowStatistics: boolean