Custom emojis support
This commit is contained in:
@@ -628,6 +628,7 @@ def update_cached_actor(actor: ap.BaseActivity) -> None:
|
||||
# {"meta.object_id": actor.id}, {"$set": {"meta.object": actor.to_dict(embed=True)}}
|
||||
# )
|
||||
_cache_actor_icon(actor)
|
||||
Tasks.cache_emojis(actor)
|
||||
|
||||
|
||||
def handle_question_reply(create: ap.Create, question: ap.Question) -> None:
|
||||
|
@@ -110,9 +110,11 @@ def _create_process_inbox(create: ap.Create, new_meta: _NewMeta) -> None:
|
||||
_logger.info(f"process_inbox activity={create!r}")
|
||||
# If it's a `Quesiion`, trigger an async task for updating it later (by fetching the remote and updating the
|
||||
# local copy)
|
||||
question = create.get_object()
|
||||
if question.has_type(ap.ActivityType.QUESTION):
|
||||
Tasks.fetch_remote_question(question)
|
||||
obj = create.get_object()
|
||||
if obj.has_type(ap.ActivityType.QUESTION):
|
||||
Tasks.fetch_remote_question(obj)
|
||||
|
||||
Tasks.cache_emojis(obj)
|
||||
|
||||
handle_replies(create)
|
||||
|
||||
|
@@ -12,6 +12,7 @@ MICROBLOGPUB = {
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"totalItems": "as:totalItems",
|
||||
"value": "schema:value",
|
||||
"Emoji": "toot:Emoji",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ from datetime import timezone
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
|
||||
from little_boxes import activitypub as ap
|
||||
from poussetaches import PousseTaches
|
||||
|
||||
from config import MEDIA_CACHE
|
||||
@@ -32,7 +33,21 @@ class Tasks:
|
||||
if MEDIA_CACHE.is_actor_icon_cached(icon_url):
|
||||
return None
|
||||
|
||||
p.push({"icon_url": icon_url, "actor_iri": actor_iri}, "/task/cache_actor_icon")
|
||||
@staticmethod
|
||||
def cache_emoji(url: str, iri: str) -> None:
|
||||
if MEDIA_CACHE.is_emoji_cached(iri):
|
||||
return None
|
||||
|
||||
p.push({"url": url, "iri": iri}, "/task/cache_emoji")
|
||||
|
||||
@staticmethod
|
||||
def cache_emojis(activity: ap.BaseActivity) -> None:
|
||||
for emoji in activity.get_emojis():
|
||||
try:
|
||||
Tasks.cache_emoji(emoji.get_icon_url(), emoji.id)
|
||||
except KeyError:
|
||||
# TODO(tsileo): log invalid emoji
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def post_to_remote_inbox(payload: str, recp: str) -> None:
|
||||
|
Reference in New Issue
Block a user