From fa997a19a14674eac752e87c32f1aedf9e2fbf0c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 25 Sep 2024 22:28:08 +0800 Subject: [PATCH] :bug: Fix getting count of stickers in pack --- pkg/internal/server/api/index.go | 1 - pkg/internal/server/api/sticker_packs_api.go | 36 -------------------- pkg/internal/server/api/stickers_api.go | 3 +- settings.toml | 9 ----- 4 files changed, 2 insertions(+), 47 deletions(-) diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index 29610cf..dd7bb66 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -25,7 +25,6 @@ func MapAPIs(app *fiber.App, baseURL string) { api.Get("/stickers/lookup", lookupStickerBatch) api.Get("/stickers/lookup/:alias", lookupSticker) - api.Get("/stickers/manifest", listStickerManifest) api.Get("/stickers/packs", listStickerPacks) api.Post("/stickers/packs", createStickerPack) api.Put("/stickers/packs/:packId", updateStickerPack) diff --git a/pkg/internal/server/api/sticker_packs_api.go b/pkg/internal/server/api/sticker_packs_api.go index 5b27a82..4c21494 100644 --- a/pkg/internal/server/api/sticker_packs_api.go +++ b/pkg/internal/server/api/sticker_packs_api.go @@ -9,42 +9,6 @@ import ( "github.com/gofiber/fiber/v2" ) -func listStickerManifest(c *fiber.Ctx) error { - take := c.QueryInt("take", 0) - offset := c.QueryInt("offset", 0) - - if take > 100 { - take = 100 - } - - tx := database.C - - if len(c.Query("author")) > 0 { - var author models.Account - if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } else { - tx = tx.Where("account_id = ?", author.ID) - } - } - - var count int64 - countTx := tx - if err := countTx.Model(&models.StickerPack{}).Count(&count).Error; err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - stickers, err := services.ListStickerPackWithStickers(tx, take, offset) - if err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - return c.JSON(fiber.Map{ - "count": count, - "data": stickers, - }) -} - func listStickerPacks(c *fiber.Ctx) error { take := c.QueryInt("take", 0) offset := c.QueryInt("offset", 0) diff --git a/pkg/internal/server/api/stickers_api.go b/pkg/internal/server/api/stickers_api.go index 7cee9f7..78e8818 100644 --- a/pkg/internal/server/api/stickers_api.go +++ b/pkg/internal/server/api/stickers_api.go @@ -54,7 +54,8 @@ func listStickers(c *fiber.Ctx) error { } var count int64 - if err := database.C.Model(&models.Sticker{}).Count(&count).Error; err != nil { + countTx := tx + if err := countTx.Model(&models.Sticker{}).Count(&count).Error; err != nil { return fiber.NewError(fiber.StatusInternalServerError, err.Error()) } diff --git a/settings.toml b/settings.toml index 35ebb20..800594a 100644 --- a/settings.toml +++ b/settings.toml @@ -2,15 +2,6 @@ id = "paperclip01" bind = "0.0.0.0:8443" grpc_bind = "0.0.0.0:7443" -domain = "usercontent.solsynth.dev" - -accepts_usage = [ - "p.avatar", - "p.banner", - "i.attachment", - "m.attachment", - "sticker", -] [workers] files_deletion = 4