9c5212de05
Add POST /manage/import (auth-protected) that fetches emotes from a legacy JSON endpoint, downloads each image, uploads it to S3, and inserts it into the DB with the original timestamps preserved. - Skip emotes whose name already exists (best-effort duplicate detection across SQLite and PostgreSQL via error code + message fallback) - Validate source_url against a configurable host allowlist ([import] allowed_hosts in config, default ["smutba.se"]) - dry_run: true previews the import without writing to S3 or DB; result statuses are "would_import" / "would_skip" instead of "imported" / "skipped" - Add db.name_exists() for efficient per-name existence checks used by dry-run - Add reqwest (rustls-tls + json) and url dependencies - Integration tests: auth guard, allowlist rejection, mirror + skip-duplicates, dry-run no-persist
35 lines
1.0 KiB
TOML
35 lines
1.0 KiB
TOML
# mikebase configuration file
|
|
# All values can be overridden by environment variables using the APP__ prefix.
|
|
# Example: APP__DATABASE__URL=sqlite://mikebase.db
|
|
|
|
[database]
|
|
# SQLite example:
|
|
url = "sqlite://mikebase.db"
|
|
# PostgreSQL example:
|
|
# url = "postgresql://user:password@localhost/mikebase"
|
|
|
|
[server]
|
|
host = "0.0.0.0"
|
|
port = 3000
|
|
|
|
[auth]
|
|
# Credentials for the /manage UI and emote write endpoints (POST/PUT/DELETE).
|
|
# Can also be set via APP__AUTH__USERNAME and APP__AUTH__PASSWORD env vars.
|
|
# If omitted, all protected routes return 401.
|
|
username = "admin"
|
|
password = "changeme"
|
|
|
|
[import]
|
|
# Hosts allowed as migration sources for POST /manage/import.
|
|
# The request is rejected unless the source URL host matches one of these.
|
|
allowed_hosts = ["smutba.se"]
|
|
|
|
[s3]
|
|
endpoint = "https://s3.eu-central-1.wasabisys.com"
|
|
region = "eu-central-1"
|
|
bucket = "open3dlab-emoji"
|
|
access_key = "YOUR_ACCESS_KEY"
|
|
secret_key = "YOUR_SECRET_KEY"
|
|
# Base URL used to construct public image URLs in API responses.
|
|
public_url = "https://s3.eu-central-1.wasabisys.com/open3dlab-emoji"
|