[lint] actor.py
This commit is contained in:
parent
64278302fa
commit
1751a78a59
1 changed files with 8 additions and 9 deletions
17
app/actor.py
17
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"]
|
||||
|
|
Loading…
Reference in a new issue