Fix DeliveryReceipt not being cleaned up

This commit is contained in:
Hubert Hirtz 2021-09-13 18:24:01 +02:00 committed by Simon Ser
parent 872ed736b4
commit 6b9c99821a

View File

@ -289,6 +289,17 @@ func (db *SqliteDB) DeleteUser(id int64) error {
} }
defer tx.Rollback() 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 _, err = tx.Exec(`DELETE FROM Channel
WHERE id IN ( WHERE id IN (
SELECT Channel.id SELECT Channel.id
@ -422,6 +433,11 @@ func (db *SqliteDB) DeleteNetwork(id int64) error {
} }
defer tx.Rollback() 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) _, err = tx.Exec("DELETE FROM Channel WHERE network = ?", id)
if err != nil { if err != nil {
return err return err