From af3142ac3adb0d1f31d160edcb6d076b293020b1 Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Thu, 15 Dec 2022 02:50:54 -0500 Subject: Basic Emoji suppport (#157) --- mediaproxy/views.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'mediaproxy') 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) -- cgit v1.2.3