🐛 Bug fixes

This commit is contained in:
LittleSheep 2024-11-03 02:14:56 +08:00
parent 2d119826fe
commit 3f9df23491
14 changed files with 244 additions and 373 deletions

View File

@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="dataSourceStorageLocal" created-in="GO-242.23339.24"> <component name="dataSourceStorageLocal" created-in="GO-242.23339.24">
<data-source name="hy_paperclip@localhost" uuid="bac83d8a-c619-4680-a07f-6674b93fbfea"> <data-source name="hy_paperclip@localhost" uuid="bac83d8a-c619-4680-a07f-6674b93fbfea">
<database-info product="PostgreSQL" version="16.3 (Homebrew)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.6.0" dbms="POSTGRES" exact-version="16.3" exact-driver-version="42.6"> <database-info product="PostgreSQL" version="16.4 (Homebrew)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.6.0" dbms="POSTGRES" exact-version="16.4" exact-driver-version="42.6">
<identifier-quote-string>&quot;</identifier-quote-string> <identifier-quote-string>&quot;</identifier-quote-string>
</database-info> </database-info>
<case-sensitivity plain-identifiers="lower" quoted-identifiers="exact" /> <case-sensitivity plain-identifiers="lower" quoted-identifiers="exact" />

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
#n:public #n:public
!<md> [10537, 0, null, null, -2147483648, -2147483648] !<md> [11316, 0, null, null, -2147483648, -2147483648]

View File

@ -4,22 +4,20 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":recycle: Migrated to nexus"> <list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":wastebasket: Remove account">
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea/storage_v2/_src_/database/hy_paperclip.LrVPOQ/schema/public.abK9xQ.meta" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea/storage_v2/_src_/database/hy_paperclip.LrVPOQ/schema/public.abK9xQ.meta" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/gap/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/gap/server.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/pools_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/pools_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/database/source.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/source.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/services.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/services.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/accounts.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/attachments.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/pools.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/pools.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/stickers.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/stickers.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/sticker_packs_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/stickers_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/up_direct_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_direct_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/attachments.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/attachments.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/main.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/services/sticker_packs.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/sticker_packs.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -131,7 +129,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":bug: Fix schedule deletion will delete referenced file" />
<MESSAGE value=":bug: Fix sql statement" /> <MESSAGE value=":bug: Fix sql statement" />
<MESSAGE value=":bug: Fix doesn't get has lifecycle settings buckets correctly" /> <MESSAGE value=":bug: Fix doesn't get has lifecycle settings buckets correctly" />
<MESSAGE value=":zap: Fix the RandString method cause the lag" /> <MESSAGE value=":zap: Fix the RandString method cause the lag" />
@ -156,7 +153,8 @@
<MESSAGE value=":bug: Trying to prevent exiftool causing analyze failed" /> <MESSAGE value=":bug: Trying to prevent exiftool causing analyze failed" />
<MESSAGE value=":bug: Fix bug crash caused by hash small files" /> <MESSAGE value=":bug: Fix bug crash caused by hash small files" />
<MESSAGE value=":recycle: Migrated to nexus" /> <MESSAGE value=":recycle: Migrated to nexus" />
<option name="LAST_COMMIT_MESSAGE" value=":recycle: Migrated to nexus" /> <MESSAGE value=":wastebasket: Remove account" />
<option name="LAST_COMMIT_MESSAGE" value=":wastebasket: Remove account" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -28,7 +28,7 @@ func InitializeToNexus() error {
Type: "uc", Type: "uc",
Label: "Paperclip", Label: "Paperclip",
GrpcAddr: grpcOutbound, GrpcAddr: grpcOutbound,
HttpAddr: lo.ToPtr("http://" + httpOutbound), HttpAddr: lo.ToPtr("http://" + httpOutbound + "/api"),
}) })
if err == nil { if err == nil {
go func() { go func() {

View File

@ -82,7 +82,7 @@ func getAttachmentMeta(c *fiber.Ctx) error {
func updateAttachmentMeta(c *fiber.Ctx) error { func updateAttachmentMeta(c *fiber.Ctx) error {
id, _ := c.ParamsInt("id", 0) id, _ := c.ParamsInt("id", 0)
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Alternative string `json:"alt"` Alternative string `json:"alt"`
@ -112,7 +112,7 @@ func updateAttachmentMeta(c *fiber.Ctx) error {
func deleteAttachment(c *fiber.Ctx) error { func deleteAttachment(c *fiber.Ctx) error {
id, _ := c.ParamsInt("id", 0) id, _ := c.ParamsInt("id", 0)
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
attachment, err := services.GetAttachmentByID(uint(id)) attachment, err := services.GetAttachmentByID(uint(id))
if err != nil { if err != nil {

View File

@ -81,7 +81,7 @@ func listAttachment(c *fiber.Ctx) error {
if needQuery { if needQuery {
var out []models.Attachment var out []models.Attachment
if err := tx.Offset(offset).Limit(take).Preload("Account").Find(&out).Error; err != nil { if err := tx.Offset(offset).Limit(take).Find(&out).Error; err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} }

View File

@ -27,7 +27,7 @@ func getPool(c *fiber.Ctx) error {
} }
func createPool(c *fiber.Ctx) error { func createPool(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Alias string `json:"alias" validate:"required"` Alias string `json:"alias" validate:"required"`
@ -56,7 +56,7 @@ func createPool(c *fiber.Ctx) error {
} }
func updatePool(c *fiber.Ctx) error { func updatePool(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Alias string `json:"alias" validate:"required"` Alias string `json:"alias" validate:"required"`
@ -88,7 +88,7 @@ func updatePool(c *fiber.Ctx) error {
} }
func deletePool(c *fiber.Ctx) error { func deletePool(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
id, _ := c.ParamsInt("id") id, _ := c.ParamsInt("id")
pool, err := services.GetAttachmentPoolWithUser(uint(id), user.ID) pool, err := services.GetAttachmentPoolWithUser(uint(id), user.ID)

View File

@ -55,7 +55,7 @@ func getStickerPack(c *fiber.Ctx) error {
} }
func createStickerPack(c *fiber.Ctx) error { func createStickerPack(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Prefix string `json:"prefix" validate:"required,alphanum,min=2,max=12"` Prefix string `json:"prefix" validate:"required,alphanum,min=2,max=12"`
@ -76,7 +76,7 @@ func createStickerPack(c *fiber.Ctx) error {
} }
func updateStickerPack(c *fiber.Ctx) error { func updateStickerPack(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Prefix string `json:"prefix" validate:"required,alphanum,min=2,max=12"` Prefix string `json:"prefix" validate:"required,alphanum,min=2,max=12"`
@ -106,7 +106,7 @@ func updateStickerPack(c *fiber.Ctx) error {
} }
func deleteStickerPack(c *fiber.Ctx) error { func deleteStickerPack(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
id, _ := c.ParamsInt("packId", 0) id, _ := c.ParamsInt("packId", 0)
pack, err := services.GetStickerPackWithUser(uint(id), user.ID) pack, err := services.GetStickerPackWithUser(uint(id), user.ID)

View File

@ -80,7 +80,7 @@ func getSticker(c *fiber.Ctx) error {
} }
func createSticker(c *fiber.Ctx) error { func createSticker(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Alias string `json:"alias" validate:"required,alphanum,min=2,max=12"` Alias string `json:"alias" validate:"required,alphanum,min=2,max=12"`
@ -125,7 +125,7 @@ func createSticker(c *fiber.Ctx) error {
} }
func updateSticker(c *fiber.Ctx) error { func updateSticker(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Alias string `json:"alias" validate:"required,alphanum,min=2,max=12"` Alias string `json:"alias" validate:"required,alphanum,min=2,max=12"`
@ -173,7 +173,7 @@ func updateSticker(c *fiber.Ctx) error {
} }
func deleteSticker(c *fiber.Ctx) error { func deleteSticker(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
id, _ := c.ParamsInt("stickerId", 0) id, _ := c.ParamsInt("stickerId", 0)
sticker, err := services.GetStickerWithUser(uint(id), user.ID) sticker, err := services.GetStickerWithUser(uint(id), user.ID)

View File

@ -12,7 +12,7 @@ import (
) )
func createAttachmentDirectly(c *fiber.Ctx) error { func createAttachmentDirectly(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
poolAlias := c.FormValue("pool") poolAlias := c.FormValue("pool")

View File

@ -13,7 +13,7 @@ import (
) )
func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error { func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
var data struct { var data struct {
Pool string `json:"pool" validate:"required"` Pool string `json:"pool" validate:"required"`
@ -69,7 +69,7 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
} }
func uploadAttachmentMultipart(c *fiber.Ctx) error { func uploadAttachmentMultipart(c *fiber.Ctx) error {
user := c.Locals("nex_user").(sec.UserInfo) user := c.Locals("nex_user").(*sec.UserInfo)
rid := c.Params("file") rid := c.Params("file")
cid := c.Params("chunk") cid := c.Params("chunk")

View File

@ -33,7 +33,7 @@ func GetAttachmentByID(id uint) (models.Attachment, error) {
var attachment models.Attachment var attachment models.Attachment
if err := database.C. if err := database.C.
Where("id = ?", id). Where("id = ?", id).
Preload("Pool").Preload("Account"). Preload("Pool").
First(&attachment).Error; err != nil { First(&attachment).Error; err != nil {
return attachment, err return attachment, err
} else { } else {
@ -59,7 +59,7 @@ func GetAttachmentByRID(rid string) (models.Attachment, error) {
var attachment models.Attachment var attachment models.Attachment
if err := database.C.Where(models.Attachment{ if err := database.C.Where(models.Attachment{
Rid: rid, Rid: rid,
}).Preload("Pool").Preload("Account").First(&attachment).Error; err != nil { }).Preload("Pool").First(&attachment).Error; err != nil {
return attachment, err return attachment, err
} else { } else {
CacheAttachment(attachment) CacheAttachment(attachment)
@ -107,7 +107,7 @@ func CacheAttachment(item models.Attachment) {
) )
} }
func NewAttachmentMetadata(tx *gorm.DB, user sec.UserInfo, file *multipart.FileHeader, attachment models.Attachment) (models.Attachment, error) { func NewAttachmentMetadata(tx *gorm.DB, user *sec.UserInfo, file *multipart.FileHeader, attachment models.Attachment) (models.Attachment, error) {
attachment.Uuid = uuid.NewString() attachment.Uuid = uuid.NewString()
attachment.Rid = RandString(16) attachment.Rid = RandString(16)
attachment.Size = file.Size attachment.Size = file.Size
@ -146,7 +146,7 @@ func NewAttachmentMetadata(tx *gorm.DB, user sec.UserInfo, file *multipart.FileH
return attachment, nil return attachment, nil
} }
func NewAttachmentPlaceholder(tx *gorm.DB, user sec.UserInfo, attachment models.Attachment) (models.Attachment, error) { func NewAttachmentPlaceholder(tx *gorm.DB, user *sec.UserInfo, attachment models.Attachment) (models.Attachment, error) {
attachment.Uuid = uuid.NewString() attachment.Uuid = uuid.NewString()
attachment.Rid = RandString(16) attachment.Rid = RandString(16)
attachment.IsUploaded = false attachment.IsUploaded = false

View File

@ -31,7 +31,7 @@ func ListStickerPackWithStickers(tx *gorm.DB, take, offset int) ([]models.Sticke
return packs, nil return packs, nil
} }
func NewStickerPack(user sec.UserInfo, prefix, name, desc string) (models.StickerPack, error) { func NewStickerPack(user *sec.UserInfo, prefix, name, desc string) (models.StickerPack, error) {
pack := models.StickerPack{ pack := models.StickerPack{
Prefix: prefix, Prefix: prefix,
Name: name, Name: name,