From 68bbd358a5e06c2ef1816af9383e2d3e0da7dfb0 Mon Sep 17 00:00:00 2001 From: ogdbd3h5qze42igcv8wcrqk3 Date: Sun, 19 Mar 2023 18:24:19 +0100 Subject: [PATCH] [mastodon] Fix delete endpoint for mastodon --- backend/src/kibicara/platforms/mastodon/webapi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/kibicara/platforms/mastodon/webapi.py b/backend/src/kibicara/platforms/mastodon/webapi.py index 421467c..c10ce44 100644 --- a/backend/src/kibicara/platforms/mastodon/webapi.py +++ b/backend/src/kibicara/platforms/mastodon/webapi.py @@ -101,6 +101,12 @@ async def mastodon_read_all(hood=Depends(get_hood)): ) async def mastodon_delete(mastodon=Depends(get_mastodon)): spawner.stop(mastodon) + await mastodon.instance.load() + object_with_instance = await MastodonAccount.objects.filter( + instance=mastodon.instance + ).all() + if len(object_with_instance) == 1 and object_with_instance[0] == mastodon: + await mastodon.instance.delete() await mastodon.delete() return Response(status_code=status.HTTP_204_NO_CONTENT)