diff options
Diffstat (limited to 'takahe')
-rw-r--r-- | takahe/settings/base.py | 59 | ||||
-rw-r--r-- | takahe/urls.py | 5 |
2 files changed, 51 insertions, 13 deletions
diff --git a/takahe/settings/base.py b/takahe/settings/base.py index 614bfd2..d2e30c3 100644 --- a/takahe/settings/base.py +++ b/takahe/settings/base.py @@ -1,5 +1,7 @@ import os +import sys from pathlib import Path +from typing import Optional BASE_DIR = Path(__file__).resolve().parent.parent.parent @@ -56,11 +58,11 @@ WSGI_APPLICATION = "takahe.wsgi.application" DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", - "HOST": os.environ.get("POSTGRES_HOST", "localhost"), - "PORT": os.environ.get("POSTGRES_PORT", 5432), - "NAME": os.environ.get("POSTGRES_DB", "takahe"), - "USER": os.environ.get("POSTGRES_USER", "postgres"), - "PASSWORD": os.environ.get("POSTGRES_PASSWORD"), + "HOST": os.environ.get("PGHOST", "localhost"), + "PORT": os.environ.get("PGPORT", 5432), + "NAME": os.environ.get("PGDATABASE", "takahe"), + "USER": os.environ.get("PGUSER", "postgres"), + "PASSWORD": os.environ.get("PGPASSWORD"), } } @@ -109,12 +111,47 @@ STATICFILES_DIRS = [ ALLOWED_HOSTS = ["*"] +### User-configurable options, pulled from the environment ### + MAIN_DOMAIN = os.environ["TAKAHE_MAIN_DOMAIN"] if "/" in MAIN_DOMAIN: print("TAKAHE_MAIN_DOMAIN should be just the domain name - no https:// or path") - -EMAIL_FROM = os.environ["TAKAHE_EMAIL_FROM"] - -# Note that this MUST be a fully qualified URL in production -MEDIA_URL = os.environ.get("TAKAHE_MEDIA_URL", "/media/") -MEDIA_ROOT = os.environ.get("TAKAHE_MEDIA_ROOT", BASE_DIR / "media") + sys.exit(1) + + +if os.environ.get("TAKAHE_EMAIL_CONSOLE_ONLY"): + EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + EMAIL_FROM = "test@example.com" +else: + EMAIL_FROM = os.environ["TAKAHE_EMAIL_FROM"] + if "TAKAHE_EMAIL_SENDGRID_KEY" in os.environ: + EMAIL_HOST = "smtp.sendgrid.net" + EMAIL_PORT = 587 + EMAIL_HOST_USER: Optional[str] = "apikey" + EMAIL_HOST_PASSWORD: Optional[str] = os.environ["TAKAHE_EMAIL_SENDGRID_KEY"] + EMAIL_USE_TLS = True + else: + EMAIL_HOST = os.environ["TAKAHE_EMAIL_HOST"] + EMAIL_PORT = int(os.environ["TAKAHE_EMAIL_PORT"]) + EMAIL_HOST_USER = os.environ.get("TAKAHE_EMAIL_USER") + EMAIL_HOST_PASSWORD = os.environ.get("TAKAHE_EMAIL_PASSWORD") + EMAIL_USE_SSL = EMAIL_PORT == 465 + EMAIL_USE_TLS = EMAIL_PORT == 587 + +AUTO_ADMIN_EMAIL = os.environ.get("TAKAHE_AUTO_ADMIN_EMAIL") + +# Set up media storage +MEDIA_BACKEND = os.environ.get("TAKAHE_MEDIA_BACKEND", None) +if MEDIA_BACKEND == "local": + # Note that this MUST be a fully qualified URL in production + MEDIA_URL = os.environ.get("TAKAHE_MEDIA_URL", "/media/") + MEDIA_ROOT = os.environ.get("TAKAHE_MEDIA_ROOT", BASE_DIR / "media") +elif MEDIA_BACKEND == "gcs": + DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage" + GS_BUCKET_NAME = os.environ["TAKAHE_MEDIA_BUCKET"] +elif MEDIA_BACKEND == "s3": + DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" + AWS_STORAGE_BUCKET_NAME = os.environ["TAKAHE_MEDIA_BUCKET"] +else: + print("Unknown TAKAHE_MEDIA_BACKEND value") + sys.exit(1) diff --git a/takahe/urls.py b/takahe/urls.py index 8c01d64..1f1b203 100644 --- a/takahe/urls.py +++ b/takahe/urls.py @@ -86,8 +86,7 @@ urlpatterns = [ ), # Identity views path("@<handle>/", identity.ViewIdentity.as_view()), - path("@<handle>/actor/", activitypub.Actor.as_view()), - path("@<handle>/actor/inbox/", activitypub.Inbox.as_view()), + path("@<handle>/inbox/", activitypub.Inbox.as_view()), path("@<handle>/action/", identity.ActionIdentity.as_view()), # Posts path("compose/", posts.Compose.as_view(), name="compose"), @@ -109,6 +108,8 @@ urlpatterns = [ # Well-known endpoints path(".well-known/webfinger", activitypub.Webfinger.as_view()), path(".well-known/host-meta", activitypub.HostMeta.as_view()), + path(".well-known/nodeinfo", activitypub.NodeInfo.as_view()), + path("nodeinfo/2.0/", activitypub.NodeInfo2.as_view()), # Task runner path(".stator/runner/", stator.RequestRunner.as_view()), # Django admin |