From a39104b336211e35b249bfce4d046d0583d2a4ad Mon Sep 17 00:00:00 2001 From: ppolariss <2673986789@qq.com> Date: Fri, 11 Oct 2024 00:25:23 +0800 Subject: [PATCH] try fix: not found in BanUserForever --- apis/penalty/api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apis/penalty/api.go b/apis/penalty/api.go index cb47dd0..f6745a8 100644 --- a/apis/penalty/api.go +++ b/apis/penalty/api.go @@ -10,6 +10,7 @@ import ( "treehole_next/utils" "github.com/opentreehole/go-common" + "github.com/rs/zerolog/log" "gorm.io/gorm" "gorm.io/gorm/clause" @@ -144,6 +145,7 @@ func BanUserForever(c *fiber.Ctx) error { if err != nil { return err } + log.Info().Msgf("ban user forever: %v", body) floorID, err := c.ParamsInt("id") if err != nil { @@ -161,6 +163,8 @@ func BanUserForever(c *fiber.Ctx) error { return common.Forbidden() } + log.Info().Msgf("ban user forever: %d", floorID) + var floor Floor err = DB.Take(&floor, floorID).Error if err != nil { @@ -181,6 +185,7 @@ func BanUserForever(c *fiber.Ctx) error { var divisionIDs []int madeBy := user.ID err = DB.Transaction(func(tx *gorm.DB) (err error) { + log.Info().Msgf("ban user forever: %d", floor.UserID) err = tx.Clauses(clause.Locking{Strength: "UPDATE"}).Take(&user, floor.UserID).Error if err != nil { return err @@ -194,6 +199,7 @@ func BanUserForever(c *fiber.Ctx) error { ExcludeBanForeverDivisionIds := config.Config.ExcludeBanForeverDivisionIds divisionIDs = utils.Difference(divisionIDs, ExcludeBanForeverDivisionIds) + log.Info().Msgf("ban user forever: %v", divisionIDs) for _, divisionID := range divisionIDs { punishment = &Punishment{ @@ -217,6 +223,7 @@ func BanUserForever(c *fiber.Ctx) error { punishments = append(punishments, punishment) } user.OffenceCount += len(divisionIDs) + log.Info().Msgf("ban user forever: %v", punishments) err = tx.Create(&punishments).Error if err != nil { @@ -233,6 +240,7 @@ func BanUserForever(c *fiber.Ctx) error { if err != nil { return err } + log.Info().Msgf("ban user forever: %v", user) // construct message for user message := Notification{ @@ -247,6 +255,7 @@ func BanUserForever(c *fiber.Ctx) error { Type: MessageTypePermission, URL: fmt.Sprintf("/api/floors/%d", floor.ID), } + log.Info().Msgf("ban user forever: %v", message) // send _, err = message.Send()