[chore] format code
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
SouthFox 2023-08-02 20:53:09 +08:00
parent 3eb22ce9db
commit da6b51fc5f
5 changed files with 20 additions and 11 deletions

View file

@ -227,9 +227,9 @@ async def process_incoming(
async def _handle_follow(
db_session : AsyncSession,
actor : Actor,
inbox_object : InboxObject,
db_session: AsyncSession,
actor: Actor,
inbox_object: InboxObject,
) -> bool:
if ME["id"] != inbox_object.ap_object["object"]: #type: ignore
# await db_session.delete(ap_object)
@ -245,9 +245,9 @@ async def _handle_follow(
async def _send_accept(
db_session: AsyncSession,
actor : Actor,
inbox_object : InboxObject,
) -> None :
actor: Actor,
inbox_object: InboxObject,
) -> None:
follower = models.Follower(
actor_id=inbox_object.actor_id,
inbox_object_id=inbox_object.id,
@ -287,8 +287,8 @@ async def _send_accept(
async def _handle_undo(
db_session : AsyncSession,
inbox_object : dict
db_session: AsyncSession,
inbox_object: dict
) -> bool:
if inbox_object["object"]["object"] != ME["id"]:
logger.warning("Wrong undo object! "

View file

@ -13,6 +13,7 @@ from app.config import DB_PATH
from app.config import DEBUG
from app.config import SQLALCHEMY_DATABASE_URL
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False, "timeout": 15}
)

View file

@ -3,6 +3,7 @@ from pathlib import Path
from Crypto.PublicKey import RSA
def get_pubkey_as_pem(key_path: Path) -> str:
text = key_path.read_text()
return RSA.import_key(text).public_key().export_key("PEM").decode("utf-8")

View file

@ -24,9 +24,11 @@ from sqlalchemy.orm import relationship
from datetime import datetime as dtime
from datetime import timezone
def now() -> dtime:
return dtime.now(timezone.utc)
class Actor(Base, BaseActor):
__tablename__ = "actor"
@ -43,6 +45,7 @@ class Actor(Base, BaseActor):
is_blocked = Column(Boolean, nullable=False, default=False, server_default="0")
is_deleted = Column(Boolean, nullable=False, default=False, server_default="0")
class InboxObject(Base, BaseObject):
__tablename__ = "inbox"
@ -90,6 +93,7 @@ class InboxObject(Base, BaseObject):
uselist=False,
)
class OutboxObject(Base, BaseObject):
__tablename__ = "outbox"
@ -147,6 +151,7 @@ class OutboxObject(Base, BaseObject):
uselist=False,
)
class IncomingActivity(Base):
__tablename__ = "ingress"
@ -156,6 +161,7 @@ class IncomingActivity(Base):
ap_id = Column(String, nullable=True, index=True)
ap_object = Column(JSON, nullable=True)
class OutcomingActivity(Base):
__tablename__ = "push"
@ -165,6 +171,7 @@ class OutcomingActivity(Base):
ap_id = Column(String, nullable=True, index=True)
ap_object = Column(JSON, nullable=True)
class Follower(Base):
__tablename__ = "follower"
@ -180,6 +187,7 @@ class Follower(Base):
ap_actor_id = Column(String, nullable=False, unique=True)
class Following(Base):
__tablename__ = "following"

View file

@ -13,8 +13,8 @@ from sqlalchemy import select
async def inbox_prechecker(
request : fastapi.Request,
db_session : AsyncSession = fastapi.Depends(get_db_session)
request: fastapi.Request,
db_session: AsyncSession = fastapi.Depends(get_db_session)
) -> bool:
"""
Check http request
@ -47,7 +47,6 @@ async def inbox_prechecker(
)
).one_or_none()
):
logger.info(f"Dropping unnecessary delete activity " +
payload["actor"])
raise fastapi.HTTPException(status_code=202)