From 47a53b6990349eee68c5988f00b2594b07a3e97a Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 17 Oct 2023 09:12:53 -1000 Subject: [PATCH] Update README and config --- README.md | 19 ++++++++++++ config/config.example.toml | 20 +++++++++++++ utils/config.ts | 60 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/README.md b/README.md index 3f6d0bba..fd9fc137 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,25 @@ Configuration can be found inside the `config.toml` file. The following values a - `banned_ips`: An array of strings representing banned IPv4 or IPv6 IPs. Wildcards, networks and ranges are supported. Example: `[ "192.168.0.*" ]` (empty array) +### Media + +- `backend`: Specifies the backend to use for media storage. Can be "local" or "s3", "local" uploads the file to the local filesystem. +- `deduplicate_media`: When set to true, the hash of media is checked when uploading to avoid duplication. + +#### Conversion + +- `convert_images`: Whether to convert uploaded images to another format. Example: `true` +- `convert_to`: The format to convert uploaded images to. Example: `"webp"`. Can be "jxl", "webp", "avif", "png", "jpg" or "gif". + +### S3 + +- `endpoint`: The endpoint to use for the S3 server. Example: `"https://s3.example.com"` +- `access_key`: Access key to use for S3 +- `secret_access_key`: Secret access key to use for S3 +- `bucket_name`: The bucket to use for S3 (can be left empty) +- `region`: The region to use for S3 (can be left empty) +- `public_url`: The public URL to access uploaded media. Example: `"https://cdn.example.com"` + ### SMTP - `server`: The SMTP server to use for sending emails. Example: `"smtp.example.com"` diff --git a/config/config.example.toml b/config/config.example.toml index 60c23b07..d4e4e935 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -21,6 +21,26 @@ username = "test@example.com" password = "password123" tls = true +[media] +# Can be "s3" or "local", where "local" uploads the file to the local filesystem +backend = "s3" # NOT IMPLEMENTED +# Whether to check the hash of media when uploading to avoid duplication +deduplicate_media = true # NOT IMPLEMENTED + +[media.conversion] +convert_images = false # NOT IMPLEMENTED +# Can be: "jxl", "webp", "avif", "png", "jpg", "gif" +convert_to = "webp" # NOT IMPLEMENTED + +[s3] +# Can be left blank if you don't use the S3 media backend +endpoint = "https://s3-us-west-2.amazonaws.com" +access_key = "" +secret_access_key = "" +region = "us-west-2" +bucket_name = "lysand" +public_url = "https://cdn.example.com" + [email] # Sends an email to moderators when a report is received # NOT IMPLEMENTED diff --git a/utils/config.ts b/utils/config.ts index fb46f025..d1cbf078 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -16,6 +16,14 @@ export interface ConfigType { banned_ips: string[]; }; + smtp: { + server: string; + port: number; + username: string; + password: string; + tls: boolean; + }; + validation: { max_displayname_size: number; max_bio_size: number; @@ -35,6 +43,24 @@ export interface ConfigType { allowed_mime_types: string[]; }; + media: { + backend: string; + deduplicate_media: boolean; + conversion: { + convert_images: boolean; + convert_to: string; + }; + }; + + s3: { + endpoint: string; + access_key: string; + secret_access_key: string; + region: string; + bucket_name: string; + public_url: string; + }; + defaults: { visibility: string; language: string; @@ -42,6 +68,12 @@ export interface ConfigType { header: string; }; + email: { + send_on_report: boolean; + send_on_suspend: boolean; + send_on_unsuspend: boolean; + }; + activitypub: { use_tombstones: boolean; reject_activities: string[]; @@ -101,6 +133,34 @@ export const configDefaults: ConfigType = { password: "postgres", database: "lysand", }, + smtp: { + password: "", + port: 465, + server: "", + tls: true, + username: "", + }, + media: { + backend: "local", + deduplicate_media: true, + conversion: { + convert_images: false, + convert_to: "webp", + }, + }, + email: { + send_on_report: false, + send_on_suspend: false, + send_on_unsuspend: false, + }, + s3: { + access_key: "", + bucket_name: "", + endpoint: "", + public_url: "", + region: "", + secret_access_key: "", + }, validation: { max_displayname_size: 50, max_bio_size: 6000,