From 523cb1f467477dc786139e1973ac2bd49be108a6 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Sun, 10 Mar 2024 02:16:14 +0800 Subject: [PATCH] [feat] add accept follow again command --- tasks.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tasks.py b/tasks.py index d696bbb..4890458 100644 --- a/tasks.py +++ b/tasks.py @@ -84,6 +84,44 @@ def follow(ctx): asyncio.run(_dodo()) +@task +def accept_follow_again(ctx): + from app.database import async_session + from sqlalchemy import select + from sqlalchemy.orm import joinedload + from app import models + from app.boxes import _send_accept + + inbox_id = prompt("enter want to accept inbox id:") + + async def _do(): + async with async_session() as db_session: #type: ignore + try: + exist_inbox = ( + await db_session.scalars( + select(models.InboxObject).where( + models.InboxObject.id == int(inbox_id) + ).options( + joinedload(models.InboxObject.actor) + ) + ) + ).one_or_none() + + await _send_accept( + db_session, + exist_inbox.actor, + exist_inbox, + ) + await db_session.commit() + except Exception as e: + print(f"ERROR: Failed to {e}") + return + + print("Done!") + + asyncio.run(_do()) + + @task def accept_follow(ctx): from app.database import async_session