summaryrefslogtreecommitdiffstats
path: root/takahe
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-10 12:16:08 -0700
committerAndrew Godwin2022-12-10 12:16:08 -0700
commit3595af7bd239f3843aff3ae06df8932cff23173d (patch)
tree84b8a0432fb89f253808be11275e2f78fc57bf42 /takahe
parent9a978786d4eac0139b5606e22c605450adbe7a12 (diff)
downloadtakahe-3595af7bd239f3843aff3ae06df8932cff23173d.tar.gz
takahe-3595af7bd239f3843aff3ae06df8932cff23173d.tar.bz2
takahe-3595af7bd239f3843aff3ae06df8932cff23173d.zip
Media proxy, caching and tuning docs
Fixes #67
Diffstat (limited to 'takahe')
-rw-r--r--takahe/settings.py13
-rw-r--r--takahe/urls.py17
2 files changed, 29 insertions, 1 deletions
diff --git a/takahe/settings.py b/takahe/settings.py
index f508952..64a523a 100644
--- a/takahe/settings.py
+++ b/takahe/settings.py
@@ -118,6 +118,12 @@ class Settings(BaseSettings):
#: Default cache backend
CACHES_DEFAULT: CacheBackendUrl | None = None
+ #: User icon (avatar) caching backend
+ CACHES_AVATARS: CacheBackendUrl | None = None
+
+ #: Media caching backend
+ CACHES_MEDIA: CacheBackendUrl | None = None
+
PGHOST: str | None = None
PGPORT: int | None = 5432
PGNAME: str = "takahe"
@@ -167,6 +173,7 @@ INSTALLED_APPS = [
"activities",
"users",
"stator",
+ "mediaproxy",
]
MIDDLEWARE = [
@@ -351,7 +358,11 @@ if SETUP.MEDIA_BACKEND:
else:
raise ValueError(f"Unsupported media backend {parsed.scheme}")
-CACHES = {"default": django_cache_url.parse(SETUP.CACHES_DEFAULT or "dummy://")}
+CACHES = {
+ "default": django_cache_url.parse(SETUP.CACHES_DEFAULT or "dummy://"),
+ "avatars": django_cache_url.parse(SETUP.CACHES_AVATARS or "dummy://"),
+ "media": django_cache_url.parse(SETUP.CACHES_MEDIA or "dummy://"),
+}
if SETUP.ERROR_EMAILS:
ADMINS = [("Admin", e) for e in SETUP.ERROR_EMAILS]
diff --git a/takahe/urls.py b/takahe/urls.py
index 66f176d..98d1cd5 100644
--- a/takahe/urls.py
+++ b/takahe/urls.py
@@ -5,6 +5,7 @@ from django.views.static import serve
from activities.views import compose, explore, follows, posts, search, timelines
from core import views as core
+from mediaproxy import views as mediaproxy
from stator import views as stator
from users.views import activitypub, admin, auth, identity, settings
@@ -176,6 +177,22 @@ urlpatterns = [
core.FlatPage.as_view(title="Server Rules", config_option="policy_rules"),
name="rules",
),
+ # Media/image proxy
+ path(
+ "proxy/identity_icon/<identity_id>/",
+ mediaproxy.IdentityIconCacheView.as_view(),
+ name="proxy_identity_icon",
+ ),
+ path(
+ "proxy/identity_image/<identity_id>/",
+ mediaproxy.IdentityImageCacheView.as_view(),
+ name="proxy_identity_image",
+ ),
+ path(
+ "proxy/post_attachment/<attachment_id>/",
+ mediaproxy.PostAttachmentCacheView.as_view(),
+ name="proxy_post_attachment",
+ ),
# Well-known endpoints and system actor
path(".well-known/webfinger", activitypub.Webfinger.as_view()),
path(".well-known/host-meta", activitypub.HostMeta.as_view()),