WIP/save to outbox
This commit is contained in:
parent
eb10c05cb5
commit
997149b529
1 changed files with 28 additions and 1 deletions
29
app/boxes.py
29
app/boxes.py
|
@ -6,7 +6,7 @@ from sqlalchemy.orm import session
|
||||||
|
|
||||||
from app import models
|
from app import models
|
||||||
from app.database import AsyncSession
|
from app.database import AsyncSession
|
||||||
from app.models import InboxObject, now
|
from app.models import InboxObject, OutboxObject, now
|
||||||
from app.activitypub import ME
|
from app.activitypub import ME
|
||||||
from app.activitypub import handle_visibility
|
from app.activitypub import handle_visibility
|
||||||
from app.config import MANUALLY_APPROVES_FOLLOWERS
|
from app.config import MANUALLY_APPROVES_FOLLOWERS
|
||||||
|
@ -198,6 +198,7 @@ async def send_follow(
|
||||||
await db_session.commit()
|
await db_session.commit()
|
||||||
await db_session.flush()
|
await db_session.flush()
|
||||||
|
|
||||||
|
|
||||||
async def _send_follow(
|
async def _send_follow(
|
||||||
db_session : AsyncSession,
|
db_session : AsyncSession,
|
||||||
actor_url : str,
|
actor_url : str,
|
||||||
|
@ -212,7 +213,33 @@ async def _send_follow(
|
||||||
"actor": ME["id"],
|
"actor": ME["id"],
|
||||||
"object": actor.ap_id,
|
"object": actor.ap_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await ap.post(
|
await ap.post(
|
||||||
actor.inbox_url,
|
actor.inbox_url,
|
||||||
out,
|
out,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def save_to_outbox(
|
||||||
|
db_session : AsyncSession,
|
||||||
|
outbox_id : str,
|
||||||
|
ap_object : dict,
|
||||||
|
relates_to_inbox_object_id: int | None = None,
|
||||||
|
relates_to_outbox_object_id: int | None = None,
|
||||||
|
relates_to_actor_id: int | None = None,
|
||||||
|
) -> OutboxObject:
|
||||||
|
|
||||||
|
outbox_object = OutboxObject(
|
||||||
|
public_id=outbox_id,
|
||||||
|
ap_object=ap_object,
|
||||||
|
relates_to_inbox_object_id=relates_to_inbox_object_id,
|
||||||
|
relates_to_outbox_object_id=relates_to_outbox_object_id,
|
||||||
|
relates_to_actor_id=relates_to_actor_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
db_session.add(outbox_object)
|
||||||
|
await db_session.flush()
|
||||||
|
await db_session.refresh(outbox_object)
|
||||||
|
|
||||||
|
return outbox_object
|
||||||
|
|
Loading…
Reference in a new issue