[feat] add accept follow again command
All checks were successful
/ run-pytest (push) Successful in 38s
All checks were successful
/ run-pytest (push) Successful in 38s
This commit is contained in:
parent
d7a02db9ab
commit
523cb1f467
1 changed files with 38 additions and 0 deletions
38
tasks.py
38
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
|
||||
|
|
Loading…
Reference in a new issue