Allow to delete webmentions
This commit is contained in:
parent
d692ec060f
commit
a435cd33c9
5 changed files with 77 additions and 1 deletions
|
@ -8,6 +8,7 @@ from fastapi import HTTPException
|
|||
from fastapi import Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from loguru import logger
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import select
|
||||
|
||||
from app import models
|
||||
|
@ -204,7 +205,13 @@ async def _handle_webmention_side_effects(
|
|||
) -> None:
|
||||
if webmention.webmention_type == models.WebmentionType.UNKNOWN:
|
||||
# TODO: recount everything
|
||||
mentioned_object.webmentions_count = mentioned_object.webmentions_count + 1
|
||||
mentioned_object.webmentions_count = await db_session.scalar(
|
||||
select(func.count(models.Webmention.id)).where(
|
||||
models.Webmention.is_deleted.is_(False),
|
||||
models.Webmention.outbox_object_id == mentioned_object.id,
|
||||
models.Webmention.webmention_type == models.WebmentionType.UNKNOWN,
|
||||
)
|
||||
)
|
||||
elif webmention.webmention_type == models.WebmentionType.LIKE:
|
||||
mentioned_object.likes_count = await _get_outbox_likes_count(
|
||||
db_session, mentioned_object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue