diff --git a/app/activitypub.py b/app/activitypub.py index 09cead3..7851368 100644 --- a/app/activitypub.py +++ b/app/activitypub.py @@ -14,8 +14,6 @@ from app.key import get_pubkey_as_pem if TYPE_CHECKING: from app.actor import Actor -_HTTPX_TRANSPORT = httpx.AsyncHTTPTransport(retries=1) - RawObject = dict[str, Any] AS_CTX = "https://www.w3.org/ns/activitystreams" AS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public" @@ -110,7 +108,7 @@ class NotAnObjectError(Exception): async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject: - async with httpx.AsyncClient(transport=_HTTPX_TRANSPORT) as client: + async with httpx.AsyncClient() as client: resp = await client.get( url, headers={ diff --git a/app/main.py b/app/main.py index a0ceac1..5f5f6b8 100644 --- a/app/main.py +++ b/app/main.py @@ -104,7 +104,7 @@ class CustomMiddleware: await self.app(scope, receive, send) return - response_details = {} + response_details = {"status_code": None} start_time = time.perf_counter() request_id = os.urandom(8).hex() diff --git a/app/scss/main.scss b/app/scss/main.scss index 74a1597..fb2e359 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -45,7 +45,7 @@ a { div.highlight { background: #f0f0f0; - padding: 10px; + padding: 0 10px; overflow: auto; display: block; margin: 20px 0; diff --git a/app/templates/lookup.html b/app/templates/lookup.html index 010d6cd..bd596b2 100644 --- a/app/templates/lookup.html +++ b/app/templates/lookup.html @@ -14,6 +14,6 @@ {% if ap_object and ap_object.ap_type in actor_types %} {{ utils.display_actor(ap_object, actors_metadata) }} {% elif ap_object %} - {{ utils.display_object_expanded(ap_object) }} + {{ utils.display_object(ap_object, actors_metadata=actors_metadata) }} {% endif %} {% endblock %} diff --git a/app/templates/utils.html b/app/templates/utils.html index 9235bde..b17d855 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -234,103 +234,10 @@ {% endif %} {% endmacro %} -{% macro display_object_expanded(object, likes=[], shares=[], webmentions=[]) %} - -
- -{{ display_actor(object.actor, {}) }} - -{% if object.summary %} -

{{ object.summary | clean_html(object) | safe }}

-{% endif %} -{% if object.sensitive and object.summary and not request.query_params.show_more == object.permalink_id %} -{{ show_more_button(object.permalink_id) }} -{% endif %} -{% if not object.sensitive or (object.sensitive and object.summary and request.query_params.show_more == object.permalink_id) %} -
- {{ object.content | clean_html(object) | safe }} -
-{% endif %} - -{{ display_og_meta(object) }} - - - -
-{{ display_attachments(object) }} -
- -{% if likes or shares %} -
- {% if likes %} -
Likes -
- {% for like in likes %} - - {{ like.actor.handle}} - - {% endfor %} -
-
- {% endif %} - - {% if shares %} -
Shares -
- {% for share in shares %} - - {{ share.actor.handle}} - - {% endfor %} -
-
- {% endif %} - - {% if webmentions %} -
Webmentions -
- {% for webmention in webmentions %} - - {{ webmention.actor_name }} - - {% endfor %} -
-
- {% endif %} -
-{% endif %} - -
- -{% endmacro %} - - -{% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False) %} +{% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False, actors_metadata={}) %} {% if object.ap_type in ["Note", "Article", "Video"] %}
- {{ display_actor(object.actor, {}, embedded=True) }} + {{ display_actor(object.actor, actors_metadata, embedded=True) }} {% if object.in_reply_to %} @@ -403,7 +310,7 @@ - {% if is_admin %} + {% if is_admin and (object.is_from_outbox or object.is_from_inbox) %}
{% endif %} {% endmacro %} - -{% macro display_object_bak(object) %} -{% if object.ap_type in ["Note", "Article", "Video"] %} -
-
- -
- {{ object.actor.display_name }} - {{ object.actor.handle }} - - - - {% if is_admin %}{{ object.visibility.value }}{% endif %} - {% if object.summary %} -

{{ object.summary | clean_html(object) | safe }}

- {% endif %} - {% if object.sensitive and object.summary and not request.query_params.show_more == object.permalink_id %} - {{ show_more_button(object.permalink_id) }} - {% endif %} - {% if not object.sensitive or (object.sensitive and object.summary and request.query_params.show_more == object.permalink_id) %} -
- {{ object.content | clean_html(object) | safe }} -
- {% endif %} -
-
- -
- {{ display_og_meta(object) }} -
-
- - {{ display_attachments(object) }} -
- - -
-{% endif %} -{% endmacro %}