refactor/process boxes

This commit is contained in:
SouthFox 2023-03-18 16:12:44 +08:00
parent cde57f2604
commit 0ff423cf9b

View file

@ -37,7 +37,9 @@ async def save_incoming(
ap_object=payload,
)
await process_incoming(db_session, payload)
db_session.add(incoming_activity)
if db_session.add(incoming_activity):
return incoming_activity
await db_session.commit()
await db_session.refresh(incoming_activity)
return incoming_activity
@ -52,21 +54,24 @@ async def process_incoming(
await _handle_follow(db_session, ap_object)
return True
return False
async def _handle_follow(
db_session: AsyncSession,
ap_object: dict,
) -> None:
) -> bool:
if ME["id"] != ap_object["object"]:
# await db_session.delete(ap_object)
logger.warning("no match follow object!" + ap_object["object"])
return
return False
if MANUALLY_APPROVES_FOLLOWERS:
# TODO
return
return False
await _send_accept(db_session, ap_object)
return True
async def _send_accept(