[perf] process relates inbox object
This commit is contained in:
parent
a605bb7a5f
commit
1ce90a297a
1 changed files with 33 additions and 5 deletions
32
app/boxes.py
32
app/boxes.py
|
@ -47,8 +47,8 @@ async def get_outbox_object(
|
|||
select(OutboxObject)
|
||||
.where(OutboxObject.ap_id == ap_id)
|
||||
.options(
|
||||
joinedload(models.OutboxObject.relates_to_inbox_object).options(
|
||||
joinedload(models.InboxObject.actor),
|
||||
joinedload(OutboxObject.relates_to_inbox_object).options(
|
||||
joinedload(InboxObject.actor),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
@ -58,6 +58,23 @@ async def get_outbox_object(
|
|||
)
|
||||
|
||||
|
||||
async def get_inbox_object(
|
||||
db_session: AsyncSession,
|
||||
ap_id: str,
|
||||
) -> InboxObject | None:
|
||||
return (
|
||||
await db_session.execute(
|
||||
select(InboxObject)
|
||||
.where(InboxObject.ap_id == ap_id)
|
||||
.options(
|
||||
joinedload(InboxObject.actor),
|
||||
joinedload(InboxObject.relates_to_inbox_object),
|
||||
joinedload(InboxObject.relates_to_outbox_object),
|
||||
)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
|
||||
|
||||
async def save_incoming(
|
||||
db_session: AsyncSession,
|
||||
payload: dict,
|
||||
|
@ -103,12 +120,21 @@ async def process_incoming(
|
|||
db_session,
|
||||
ap_object["object"]["id"],
|
||||
)
|
||||
relates_to_inbox_object = await get_inbox_object(
|
||||
db_session,
|
||||
ap_object["object"]["id"]
|
||||
)
|
||||
else:
|
||||
if ap_object["object"].startswith(BASE_URL):
|
||||
relates_to_outbox_object = await get_outbox_object(
|
||||
db_session,
|
||||
ap_object["object"],
|
||||
)
|
||||
relates_to_inbox_object = await get_inbox_object(
|
||||
db_session,
|
||||
ap_object["object"]
|
||||
)
|
||||
|
||||
|
||||
def build_object(
|
||||
object,
|
||||
|
@ -221,6 +247,8 @@ async def process_incoming(
|
|||
relates_to_inbox_object=relates_to_inbox_object,
|
||||
):
|
||||
return True
|
||||
elif "Create" == ap_object["type"]:
|
||||
pass
|
||||
|
||||
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue