summaryrefslogtreecommitdiffstats
path: root/takahe
diff options
context:
space:
mode:
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()),