From 6b9c99821a4f43c03464aa7064d08a7ce9b4161d Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Mon, 13 Sep 2021 18:24:01 +0200 Subject: [PATCH] Fix DeliveryReceipt not being cleaned up --- db_sqlite.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/db_sqlite.go b/db_sqlite.go index 393f9d6..9838ae7 100644 --- a/db_sqlite.go +++ b/db_sqlite.go @@ -289,6 +289,17 @@ func (db *SqliteDB) DeleteUser(id int64) error { } defer tx.Rollback() + _, err = tx.Exec(`DELETE FROM DeliveryReceipt + WHERE id IN ( + SELECT DeliveryReceipt.id + FROM DeliveryReceipt + JOIN Network ON DeliveryReceipt.network = Network.id + WHERE Network.user = ? + )`, id) + if err != nil { + return err + } + _, err = tx.Exec(`DELETE FROM Channel WHERE id IN ( SELECT Channel.id @@ -422,6 +433,11 @@ func (db *SqliteDB) DeleteNetwork(id int64) error { } defer tx.Rollback() + _, err = tx.Exec("DELETE FROM DeliveryReceipt WHERE network = ?", id) + if err != nil { + return err + } + _, err = tx.Exec("DELETE FROM Channel WHERE network = ?", id) if err != nil { return err