summaryrefslogtreecommitdiffstats
path: root/mediaproxy
diff options
context:
space:
mode:
authorMichael Manfre2022-12-15 02:50:54 -0500
committerGitHub2022-12-15 00:50:54 -0700
commitaf3142ac3adb0d1f31d160edcb6d076b293020b1 (patch)
tree73cfd5d447f6444602c2ff401399d567c673949b /mediaproxy
parent69f1b3168ac3f29fc4bafba0418769248b10062a (diff)
downloadtakahe-af3142ac3adb0d1f31d160edcb6d076b293020b1.tar.gz
takahe-af3142ac3adb0d1f31d160edcb6d076b293020b1.tar.bz2
takahe-af3142ac3adb0d1f31d160edcb6d076b293020b1.zip
Basic Emoji suppport (#157)
Diffstat (limited to 'mediaproxy')
-rw-r--r--mediaproxy/views.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/mediaproxy/views.py b/mediaproxy/views.py
index 57257f3..4fc09b1 100644
--- a/mediaproxy/views.py
+++ b/mediaproxy/views.py
@@ -5,7 +5,7 @@ from django.http import Http404, HttpResponse
from django.shortcuts import get_object_or_404
from django.views.generic import View
-from activities.models import PostAttachment
+from activities.models import Emoji, PostAttachment
from users.models import Identity
@@ -57,6 +57,21 @@ class BaseCacheView(View):
raise NotImplementedError()
+class EmojiCacheView(BaseCacheView):
+ """
+ Caches Emoji
+ """
+
+ item_timeout = 86400 * 7 # One week
+
+ def get_remote_url(self):
+ self.emoji = get_object_or_404(Emoji, pk=self.kwargs["emoji_id"])
+
+ if not self.emoji.remote_url:
+ raise Http404()
+ return self.emoji.remote_url
+
+
class IdentityIconCacheView(BaseCacheView):
"""
Caches identity icons (avatars)