diff --git a/app/actor.py b/app/actor.py index 341920d..b093f4c 100644 --- a/app/actor.py +++ b/app/actor.py @@ -10,15 +10,13 @@ from app import models from app.database import AsyncSession - if typing.TYPE_CHECKING: from app.models import Actor as ActorModel - async def fetch_actor( - db_session : AsyncSession, - actor_id : str, + db_session: AsyncSession, + actor_id: str, ) -> "ActorModel": """Fetch actor on db, if not exist will be grabed and stored in db.""" @@ -39,8 +37,8 @@ async def fetch_actor( async def save_actor( - ap_object : dict, - db_session : AsyncSession + ap_object: dict, + db_session: AsyncSession ) -> "ActorModel": """Save actor to db.""" logger.info("save actor " + ap_object["id"]) @@ -57,8 +55,8 @@ async def save_actor( return actor -def _handle ( - ap_object :dict +def _handle( + ap_object: dict, ) -> str: ap_id = urlparse(ap_object["id"]) if not ap_id.hostname: @@ -76,7 +74,8 @@ async def get_public_key( """Give key id and reutrn public key.""" existing_actor = ( await db_session.scalars( - select(models.Actor).where(models.Actor.ap_id == key_id.split("#")[0]) + select(models.Actor).where( + models.Actor.ap_id == key_id.split("#")[0]) ) ).one_or_none() public_key = existing_actor.ap_object["publicKey"]["publicKeyPem"]