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