refactor/process boxes
This commit is contained in:
parent
cde57f2604
commit
0ff423cf9b
1 changed files with 10 additions and 5 deletions
15
app/boxes.py
15
app/boxes.py
|
@ -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
|
||||
|
@ -50,23 +52,26 @@ async def process_incoming(
|
|||
|
||||
if "Follow" == ap_object["type"]:
|
||||
await _handle_follow(db_session, ap_object)
|
||||
return True
|
||||
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(
|
||||
|
|
Loading…
Reference in a new issue