diff --git a/app/admin.py b/app/admin.py index 49fa650..ffe6215 100644 --- a/app/admin.py +++ b/app/admin.py @@ -270,6 +270,9 @@ async def admin_outbox( joinedload(models.OutboxObject.relates_to_inbox_object), joinedload(models.OutboxObject.relates_to_outbox_object), joinedload(models.OutboxObject.relates_to_actor), + joinedload(models.OutboxObject.outbox_object_attachments).options( + joinedload(models.OutboxObjectAttachment.upload) + ), ) .order_by(models.OutboxObject.ap_published_at.desc()) .limit(page_size) @@ -317,7 +320,11 @@ async def get_notifications( .options( joinedload(models.Notification.actor), joinedload(models.Notification.inbox_object), - joinedload(models.Notification.outbox_object), + joinedload(models.Notification.outbox_object).options( + joinedload( + models.OutboxObject.outbox_object_attachments + ).options(joinedload(models.OutboxObjectAttachment.upload)), + ), ) .order_by(models.Notification.created_at.desc()) ) diff --git a/app/ap_object.py b/app/ap_object.py index 5c2224c..92b6920 100644 --- a/app/ap_object.py +++ b/app/ap_object.py @@ -11,7 +11,6 @@ from app.actor import LOCAL_ACTOR from app.actor import Actor from app.actor import RemoteActor from app.media import proxied_media_url -from app.utils import opengraph class Object: @@ -199,13 +198,9 @@ class RemoteObject(Object): ) self._og_meta = None - if self.ap_type == "Note": - self._og_meta = opengraph.og_meta_from_note(self._raw_object) @property def og_meta(self) -> list[dict[str, Any]] | None: - if self._og_meta: - return [og_meta.dict() for og_meta in self._og_meta] return None @property diff --git a/app/boxes.py b/app/boxes.py index f68f5cb..bd11431 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -30,6 +30,7 @@ from app.database import now from app.outgoing_activities import new_outgoing_activity from app.source import markdownify from app.uploads import upload_to_attachment +from app.utils import opengraph AnyboxObject = models.InboxObject | models.OutboxObject @@ -60,7 +61,7 @@ async def save_outbox_object( ap_context=ra.ap_context, ap_object=ra.ap_object, visibility=ra.visibility, - og_meta=ra.og_meta, + og_meta=await opengraph.og_meta_from_note(ra.ap_object), relates_to_inbox_object_id=relates_to_inbox_object_id, relates_to_outbox_object_id=relates_to_outbox_object_id, relates_to_actor_id=relates_to_actor_id, diff --git a/app/templates/utils.html b/app/templates/utils.html index 61649c2..6284c10 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -168,6 +168,26 @@ {% endmacro %} +{% macro display_og_meta(object) %} +{% if object.og_meta %} +{% for og_meta in object.og_meta %} +
{{ og_meta.description }}
{% endif %} + {{ og_meta.site_name }} +