🐛 Fix getting count of stickers in pack
This commit is contained in:
parent
f7ab3bfb18
commit
fa997a19a1
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user