[feat] process like activity
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0d690add79
commit
a4014e85c7
1 changed files with 34 additions and 1 deletions
35
app/boxes.py
35
app/boxes.py
|
@ -194,6 +194,23 @@ async def process_incoming(
|
|||
relates_to_inbox_object=relates_to_inbox_object,
|
||||
):
|
||||
return True
|
||||
elif "Like" == ap_object["type"]:
|
||||
inbox_object = build_object(
|
||||
ap_object,
|
||||
relates_to_inbox_object=relates_to_inbox_object,
|
||||
relates_to_outbox_object=relates_to_outbox_object,
|
||||
)
|
||||
db_session.add(inbox_object)
|
||||
await db_session.flush()
|
||||
await db_session.refresh(inbox_object)
|
||||
|
||||
if await _handle_like(
|
||||
db_session,
|
||||
inbox_object,
|
||||
relates_to_outbox_object=relates_to_outbox_object,
|
||||
relates_to_inbox_object=relates_to_inbox_object,
|
||||
):
|
||||
return True
|
||||
|
||||
|
||||
return False
|
||||
|
@ -311,7 +328,7 @@ async def _handle_announce(
|
|||
relates_to_inbox_object: models.InboxObject | None,
|
||||
) -> bool :
|
||||
if relates_to_outbox_object:
|
||||
relates_to_outbox_object.announces_count = (
|
||||
relates_to_outbox_object.announces_count = ( # type: ignore
|
||||
models.OutboxObject.announces_count + 1
|
||||
)
|
||||
logger.info(f"announces +1 {relates_to_outbox_object.ap_id}")
|
||||
|
@ -320,6 +337,22 @@ async def _handle_announce(
|
|||
return False
|
||||
|
||||
|
||||
async def _handle_like(
|
||||
db_session: AsyncSession,
|
||||
inbox_object: InboxObject,
|
||||
relates_to_outbox_object: models.OutboxObject | None,
|
||||
relates_to_inbox_object: models.InboxObject | None,
|
||||
) -> bool :
|
||||
if relates_to_outbox_object:
|
||||
relates_to_outbox_object.likes_count = ( # type: ignore
|
||||
models.OutboxObject.likes_count + 1
|
||||
)
|
||||
logger.info(f"likes +1 {relates_to_outbox_object.ap_id}")
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
async def _send_follow(
|
||||
db_session : AsyncSession,
|
||||
actor_url : str,
|
||||
|
|
Loading…
Reference in a new issue