From e5b76c120e27bad7c6e4ec323ffc2e65d7dfb654 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 16 Dec 2022 20:04:28 -0700 Subject: [PATCH] Fetch emoji for user profiles --- core/models/config.py | 2 +- static/css/style.css | 6 +++++- users/models/identity.py | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/models/config.py b/core/models/config.py index 48da7de..a651396 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -225,7 +225,7 @@ class Config(models.Model): hashtag_unreviewed_are_public: bool = True hashtag_stats_max_age: int = 60 * 60 - emoji_unreviewed_are_public: bool = False + emoji_unreviewed_are_public: bool = True cache_timeout_page_default: int = 60 cache_timeout_page_timeline: int = 60 * 3 diff --git a/static/css/style.css b/static/css/style.css index 200a74b..aa68280 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -341,6 +341,10 @@ body.no-sidebar .right-column { text-transform: uppercase; } +img.emoji { + height: 0.8em; +} + /* Icon menus */ .icon-menu .option { @@ -377,7 +381,7 @@ body.no-sidebar .right-column { } .icon-menu .option img.emoji { - height: 22px; + height: 20px; } .icon-menu .option i { diff --git a/users/models/identity.py b/users/models/identity.py index 9462fee..a1167e5 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -429,6 +429,8 @@ class Identity(StatorModel): Fetches the user's actor information, as well as their domain from webfinger if it's available. """ + from activities.models import Emoji + if self.local: raise ValueError("Cannot fetch local identities") try: @@ -501,6 +503,11 @@ class Identity(StatorModel): self.domain = await get_domain(actor_url_parts.hostname) else: self.domain = await get_domain(actor_url_parts.hostname) + # Emojis (we need the domain so we do them here) + for tag in get_list(document, "tag"): + if tag["type"].lower() == "toot:emoji": + await sync_to_async(Emoji.by_ap_tag)(self.domain, tag, create=True) + # Mark as fetched self.fetched = timezone.now() try: await sync_to_async(self.save)()