database/sqlite: delete push subscriptions and msgstore in DeleteUser

This commit is contained in:
Simon Ser 2023-03-17 10:23:37 +01:00
parent a30ca70713
commit d2067f74d8

View File

@ -619,6 +619,35 @@ func (db *SqliteDB) DeleteUser(ctx context.Context, id int64) error {
return err
}
_, err = tx.ExecContext(ctx, `DELETE FROM Message
WHERE id IN (
SELECT Message.id
FROM Message, MessageTarget, Network
WHERE Message.target = MessageTarget.id
AND MessageTarget.network = Network.id
AND Network.user = ?
)`, id)
if err != nil {
return err
}
_, err = tx.ExecContext(ctx, `DELETE FROM MessageTarget
WHERE id IN (
SELECT MessageTarget.id
FROM MessageTarget, Network
WHERE MessageTarget.network = Network.id
AND Network.user = ?
)`)
if err != nil {
return err
}
_, err = tx.ExecContext(ctx, `DELETE FROM WebPushSubscription
WHERE user = ?`, id)
if err != nil {
return err
}
_, err = tx.ExecContext(ctx, `DELETE FROM Channel
WHERE id IN (
SELECT Channel.id