From 0e7e7e6d5503793b8e756f736ed71814ecf8654b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 12 Jul 2024 13:31:39 +0800 Subject: [PATCH] :bug: Fix recycle account error --- pkg/internal/services/accounts.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/accounts.go b/pkg/internal/services/accounts.go index c1f82eb..580da38 100644 --- a/pkg/internal/services/accounts.go +++ b/pkg/internal/services/accounts.go @@ -2,10 +2,11 @@ package services import ( "fmt" + "time" + "github.com/rs/zerolog/log" "github.com/spf13/viper" "gorm.io/datatypes" - "time" "git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/models" @@ -207,7 +208,6 @@ func DeleteAccount(id uint) error { &models.AuthTicket{}, &models.MagicToken{}, &models.ThirdClient{}, - &models.Notification{}, &models.NotificationSubscriber{}, &models.AccountFriendship{}, } { @@ -217,6 +217,11 @@ func DeleteAccount(id uint) error { } } + if err := tx.Delete(&models.Notification{}, "recipient_id = ?", id).Error; err != nil { + tx.Rollback() + return err + } + if err := tx.Delete(&models.Account{}, "id = ?", id).Error; err != nil { tx.Rollback() return err