diff --git a/app/actor.py b/app/actor.py index b093f4c..b17b767 100644 --- a/app/actor.py +++ b/app/actor.py @@ -1,11 +1,13 @@ #!/usr/bin/env python3 """Actor stuff.""" import typing +import hy + from urllib.parse import urlparse from sqlalchemy import select from loguru import logger -import app.activitypub as ap +from app.hyap import fetch # type: ignore from app import models from app.database import AsyncSession @@ -31,7 +33,7 @@ async def fetch_actor( if exist_actor: return exist_actor - ap_object = await ap.fetch(actor_id) + ap_object = await fetch(actor_id) exist_actor = await save_actor(ap_object, db_session) return exist_actor diff --git a/app/hyap.hy b/app/hyap.hy new file mode 100644 index 0000000..9ba82e3 --- /dev/null +++ b/app/hyap.hy @@ -0,0 +1,13 @@ +#!/usr/bin/env hy +(import httpx) +(import loguru [logger]) +(import app [config]) + +(defn/a fetch + [url] + (.info logger url) + (return (.json + (with/a [client (.AsyncClient httpx)] + (await (.get client url :headers + {"User-Agent" config.USER_AGENT + "Accept" config.AP_CONTENT_TYPE}))))))