From 3f9df234914dec3b4d9c19ed2693600fe6c7309c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 3 Nov 2024 02:14:56 +0800 Subject: [PATCH] :bug: Bug fixes --- .idea/dataSources.local.xml | 2 +- .../bac83d8a-c619-4680-a07f-6674b93fbfea.xml | 545 +++++++----------- .../schema/public.abK9xQ.meta | 2 +- .idea/workspace.xml | 26 +- pkg/internal/gap/server.go | 2 +- pkg/internal/server/api/attachments_api.go | 4 +- pkg/internal/server/api/index_api.go | 2 +- pkg/internal/server/api/pools_api.go | 6 +- pkg/internal/server/api/sticker_packs_api.go | 6 +- pkg/internal/server/api/stickers_api.go | 6 +- pkg/internal/server/api/up_direct_api.go | 2 +- pkg/internal/server/api/up_multipart_api.go | 4 +- pkg/internal/services/attachments.go | 8 +- pkg/internal/services/sticker_packs.go | 2 +- 14 files changed, 244 insertions(+), 373 deletions(-) diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index 2320523..3e90cb8 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -2,7 +2,7 @@ - + " diff --git a/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml b/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml index 307511d..7def46e 100644 --- a/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml +++ b/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea.xml @@ -3,9 +3,9 @@ mdy - 10537 - 16.3 - 1723878567 + 11316 + 16.4 + 1730514664 true ACDT true ACSST false ACST @@ -46,9 +46,9 @@ false Africa/Bissau false Africa/Blantyre false Africa/Brazzaville false Africa/Bujumbura -true Africa/Cairo +false Africa/Cairo false Africa/Casablanca -true Africa/Ceuta +false Africa/Ceuta false Africa/Conakry false Africa/Dakar false Africa/Dar_es_Salaam @@ -106,7 +106,7 @@ false America/Argentina/San_Luis false America/Argentina/Tucuman false America/Argentina/Ushuaia false America/Aruba -false America/Asuncion +true America/Asuncion false America/Atikokan true America/Atka false America/Bahia @@ -149,7 +149,7 @@ false America/Fort_Nelson true America/Fort_Wayne false America/Fortaleza true America/Glace_Bay -true America/Godthab +false America/Godthab true America/Goose_Bay true America/Grand_Turk false America/Grenada @@ -209,7 +209,7 @@ false America/Noronha true America/North_Dakota/Beulah true America/North_Dakota/Center true America/North_Dakota/New_Salem -true America/Nuuk +false America/Nuuk true America/Ojinaga false America/Panama true America/Pangnirtung @@ -230,10 +230,10 @@ false America/Rio_Branco false America/Rosario true America/Santa_Isabel false America/Santarem -false America/Santiago +true America/Santiago false America/Santo_Domingo false America/Sao_Paulo -true America/Scoresbysund +false America/Scoresbysund true America/Shiprock true America/Sitka false America/St_Barthelemy @@ -258,16 +258,16 @@ true America/Yellowknife false Antarctica/Casey false Antarctica/Davis false Antarctica/DumontDUrville -false Antarctica/Macquarie +true Antarctica/Macquarie false Antarctica/Mawson -false Antarctica/McMurdo +true Antarctica/McMurdo false Antarctica/Palmer false Antarctica/Rothera -false Antarctica/South_Pole +true Antarctica/South_Pole false Antarctica/Syowa -true Antarctica/Troll +false Antarctica/Troll false Antarctica/Vostok -true Arctic/Longyearbyen +false Arctic/Longyearbyen false Asia/Aden false Asia/Almaty false Asia/Amman @@ -282,7 +282,7 @@ false Asia/Bahrain false Asia/Baku false Asia/Bangkok false Asia/Barnaul -true Asia/Beirut +false Asia/Beirut false Asia/Bishkek false Asia/Brunei false Asia/Calcutta @@ -297,10 +297,10 @@ false Asia/Dhaka false Asia/Dili false Asia/Dubai false Asia/Dushanbe -true Asia/Famagusta -true Asia/Gaza +false Asia/Famagusta +false Asia/Gaza false Asia/Harbin -true Asia/Hebron +false Asia/Hebron false Asia/Ho_Chi_Minh false Asia/Hong_Kong false Asia/Hovd @@ -308,7 +308,7 @@ false Asia/Irkutsk false Asia/Istanbul false Asia/Jakarta false Asia/Jayapura -true Asia/Jerusalem +false Asia/Jerusalem false Asia/Kabul false Asia/Kamchatka false Asia/Karachi @@ -327,7 +327,7 @@ false Asia/Magadan false Asia/Makassar false Asia/Manila false Asia/Muscat -true Asia/Nicosia +false Asia/Nicosia false Asia/Novokuznetsk false Asia/Novosibirsk false Asia/Omsk @@ -351,7 +351,7 @@ false Asia/Taipei false Asia/Tashkent false Asia/Tbilisi false Asia/Tehran -true Asia/Tel_Aviv +false Asia/Tel_Aviv false Asia/Thimbu false Asia/Thimphu false Asia/Tokyo @@ -367,41 +367,41 @@ false Asia/Yakutsk false Asia/Yangon false Asia/Yekaterinburg false Asia/Yerevan -true Atlantic/Azores +false Atlantic/Azores true Atlantic/Bermuda -true Atlantic/Canary +false Atlantic/Canary false Atlantic/Cape_Verde -true Atlantic/Faeroe -true Atlantic/Faroe -true Atlantic/Jan_Mayen -true Atlantic/Madeira +false Atlantic/Faeroe +false Atlantic/Faroe +false Atlantic/Jan_Mayen +false Atlantic/Madeira false Atlantic/Reykjavik false Atlantic/South_Georgia false Atlantic/St_Helena false Atlantic/Stanley -false Australia/ACT -false Australia/Adelaide +true Australia/ACT +true Australia/Adelaide false Australia/Brisbane -false Australia/Broken_Hill -false Australia/Canberra -false Australia/Currie +true Australia/Broken_Hill +true Australia/Canberra +true Australia/Currie false Australia/Darwin false Australia/Eucla -false Australia/Hobart -false Australia/LHI +true Australia/Hobart +true Australia/LHI false Australia/Lindeman -false Australia/Lord_Howe -false Australia/Melbourne -false Australia/NSW +true Australia/Lord_Howe +true Australia/Melbourne +true Australia/NSW false Australia/North false Australia/Perth false Australia/Queensland -false Australia/South -false Australia/Sydney -false Australia/Tasmania -false Australia/Victoria +true Australia/South +true Australia/Sydney +true Australia/Tasmania +true Australia/Victoria false Australia/West -false Australia/Yancowinna +true Australia/Yancowinna true BDST false BDT false BNT @@ -428,7 +428,7 @@ false CHAST false CHUT false CKT true CLST -false CLT +true CLT false COT false CST true CST6CDT @@ -441,13 +441,13 @@ true Canada/Newfoundland true Canada/Pacific false Canada/Saskatchewan false Canada/Yukon -false Chile/Continental -false Chile/EasterIsland +true Chile/Continental +true Chile/EasterIsland true Cuba false DAVT false DDUT -false EASST -false EAST +true EASST +true EAST false EAT true EDT true EEST @@ -457,8 +457,8 @@ true EGST false EGT false EST true EST5EDT -true Egypt -false Eire +false Egypt +true Eire false Etc/GMT false Etc/GMT+0 false Etc/GMT+1 @@ -494,70 +494,70 @@ false Etc/UCT false Etc/UTC false Etc/Universal false Etc/Zulu -true Europe/Amsterdam -true Europe/Andorra +false Europe/Amsterdam +false Europe/Andorra false Europe/Astrakhan -true Europe/Athens -true Europe/Belfast -true Europe/Belgrade -true Europe/Berlin -true Europe/Bratislava -true Europe/Brussels -true Europe/Bucharest -true Europe/Budapest -true Europe/Busingen -true Europe/Chisinau -true Europe/Copenhagen -false Europe/Dublin -true Europe/Gibraltar -true Europe/Guernsey -true Europe/Helsinki -true Europe/Isle_of_Man +false Europe/Athens +false Europe/Belfast +false Europe/Belgrade +false Europe/Berlin +false Europe/Bratislava +false Europe/Brussels +false Europe/Bucharest +false Europe/Budapest +false Europe/Busingen +false Europe/Chisinau +false Europe/Copenhagen +true Europe/Dublin +false Europe/Gibraltar +false Europe/Guernsey +false Europe/Helsinki +false Europe/Isle_of_Man false Europe/Istanbul -true Europe/Jersey +false Europe/Jersey false Europe/Kaliningrad -true Europe/Kiev +false Europe/Kiev false Europe/Kirov -true Europe/Kyiv -true Europe/Lisbon -true Europe/Ljubljana -true Europe/London -true Europe/Luxembourg -true Europe/Madrid -true Europe/Malta -true Europe/Mariehamn +false Europe/Kyiv +false Europe/Lisbon +false Europe/Ljubljana +false Europe/London +false Europe/Luxembourg +false Europe/Madrid +false Europe/Malta +false Europe/Mariehamn false Europe/Minsk -true Europe/Monaco +false Europe/Monaco false Europe/Moscow -true Europe/Nicosia -true Europe/Oslo -true Europe/Paris -true Europe/Podgorica -true Europe/Prague -true Europe/Riga -true Europe/Rome +false Europe/Nicosia +false Europe/Oslo +false Europe/Paris +false Europe/Podgorica +false Europe/Prague +false Europe/Riga +false Europe/Rome false Europe/Samara -true Europe/San_Marino -true Europe/Sarajevo +false Europe/San_Marino +false Europe/Sarajevo false Europe/Saratov false Europe/Simferopol -true Europe/Skopje -true Europe/Sofia -true Europe/Stockholm -true Europe/Tallinn -true Europe/Tirane -true Europe/Tiraspol +false Europe/Skopje +false Europe/Sofia +false Europe/Stockholm +false Europe/Tallinn +false Europe/Tirane +false Europe/Tiraspol false Europe/Ulyanovsk -true Europe/Uzhgorod -true Europe/Vaduz -true Europe/Vatican -true Europe/Vienna -true Europe/Vilnius +false Europe/Uzhgorod +false Europe/Vaduz +false Europe/Vatican +false Europe/Vienna +false Europe/Vilnius false Europe/Volgograd -true Europe/Warsaw -true Europe/Zagreb -true Europe/Zaporozhye -true Europe/Zurich +false Europe/Warsaw +false Europe/Zagreb +false Europe/Zaporozhye +false Europe/Zurich false FET true FJST false FJT @@ -568,8 +568,8 @@ false FNT false Factory false GALT false GAMT -true GB -true GB-Eire +false GB +false GB-Eire false GEST false GET false GFT @@ -603,7 +603,7 @@ false Indian/Mauritius false Indian/Mayotte false Indian/Reunion false Iran -true Israel +false Israel false JAYT false JST false Jamaica @@ -616,7 +616,7 @@ false KRAST false KRAT false KST false Kwajalein -false LHDT +true LHDT false LHST false LIGT false LINT @@ -629,7 +629,7 @@ false MAWT true MDT true MEST true MESZ -true MET +false MET true METDST false MEZ false MHT @@ -653,8 +653,8 @@ false NOVT false NPT false NST false NUT -false NZ -false NZ-CHAT +true NZ +true NZ-CHAT true NZDT false NZST false NZT @@ -677,13 +677,13 @@ false PST true PST8PDT false PWT true PYST -false PYT +true PYT false Pacific/Apia -false Pacific/Auckland +true Pacific/Auckland false Pacific/Bougainville -false Pacific/Chatham +true Pacific/Chatham false Pacific/Chuuk -false Pacific/Easter +true Pacific/Easter false Pacific/Efate false Pacific/Enderbury false Pacific/Fakaofo @@ -704,7 +704,7 @@ false Pacific/Marquesas false Pacific/Midway false Pacific/Nauru false Pacific/Niue -false Pacific/Norfolk +true Pacific/Norfolk false Pacific/Noumea false Pacific/Pago_Pago false Pacific/Palau @@ -722,8 +722,8 @@ false Pacific/Truk false Pacific/Wake false Pacific/Wallis false Pacific/Yap -true Poland -true Portugal +false Poland +false Portugal false RET false ROC false ROK @@ -774,7 +774,7 @@ false WAKT false WAST false WAT true WDT -true WET +false WET true WETDST false WFT true WGST @@ -808,7 +808,7 @@ false Zulu 13474||10|C|G 13474||-9223372036854775808|U|G 13474||10|U|G - 10537 + 11316 47537 postgres @@ -4245,21 +4245,13 @@ false Zulu standard public schema 1 - 10537 - 2024-08-18.08:50:30 + 11316 + 2024-11-02.17:51:31 2200 523 pg_database_owner - - 47538 - 1 - 1 - 10519 - bigint|0s - postgres - - + 47610 1 1 @@ -4267,7 +4259,7 @@ false Zulu bigint|0s postgres - + 47548 1 1 @@ -4275,7 +4267,7 @@ false Zulu bigint|0s postgres - + 47568 1 1 @@ -4283,7 +4275,7 @@ false Zulu bigint|0s postgres - + 47583 1 1 @@ -4291,134 +4283,31 @@ false Zulu bigint|0s postgres - - 47539 - 10521 - 2 - postgres -
- +
47611105312postgres
- +
47549 - 10530 + 105592postgres
- +
47569105232postgres
- +
47584105252postgres
- - nextval('paperclip_accounts_id_seq'::regclass) - 1 - 1 - 10519 - bigint|0s - 47538 - 20 - - - 2 - 10519 - timestamp with time zone|0s - 1184 - - - 3 - 10519 - timestamp with time zone|0s - 1184 - - - 4 - 10519 - timestamp with time zone|0s - 1184 - - - 5 - 10519 - text|0s - 25 - - - 6 - 10519 - text|0s - 25 - - - 7 - 10519 - text|0s - 25 - - - 8 - 10519 - text|0s - 25 - - - 9 - 10519 - text|0s - 25 - - - 10 - 10519 - text|0s - 25 - - - 11 - 10519 - bigint|0s - 20 - - - 12 - 10519 - bigint|0s - 20 - - - id - 1 - 47545 - 1 - 10519 - 1 - 403 - - - deleted_at - 47547 - 10520 - 403 - - - 1 - 47546 - 1 - 10519 - 47545 - - + nextval('paperclip_attachment_pools_id_seq'::regclass) 1 1 @@ -4427,62 +4316,55 @@ false Zulu 47610 20 - + 2 10531 timestamp with time zone|0s 1184 - + 3 10531 timestamp with time zone|0s 1184 - + 4 10531 timestamp with time zone|0s 1184 - + 5 10531 text|0s 25 - + 6 10531 text|0s 25 - + 7 10531 text|0s 25 - + 8 10531 jsonb|0s 3802 - + 9 10531 bigint|0s 20 - - account_id - 47619 - 10531 - 1 - 47539 - - + id 1 47617 @@ -4491,20 +4373,20 @@ false Zulu 1 403 - + deleted_at 47624 10532 403 - + 1 47618 1 10531 47617 - + nextval('paperclip_attachments_id_seq'::regclass) 1 1 @@ -4513,154 +4395,159 @@ false Zulu 47548 20 - + 2 10521 timestamp with time zone|0s 1184 - + 3 10521 timestamp with time zone|0s 1184 - + 4 10521 timestamp with time zone|0s 1184 - + 5 10521 text|0s 25 - + 6 10521 bigint|0s 20 - + 7 10521 text|0s 25 - + 8 10521 text|0s 25 - + 9 10521 text|0s 25 - + 10 10521 text|0s 25 - + 11 10521 text|0s 25 - + 12 10521 smallint|0s 21 - + 13 10521 bigint|0s 20 - + 14 10521 jsonb|0s 3802 - + 15 10521 boolean|0s 16 - + 16 10521 boolean|0s 16 - + 17 10521 bigint|0s 20 - + 18 10521 bigint|0s 20 - + 19 10527 text|0s 25 - + 20 10528 timestamp with time zone|0s 1184 - + 21 10529 boolean|0s 16 - + 22 10530 bigint|0s 20 - + + 23 + 10558 + jsonb|0s + 3802 + + + 24 + 10559 + boolean|0s + 16 + + ref_id 47557 10521 1 47549 - - account_id - 47562 - 10521 - 1 - 47539 - - + pool_id 47625 10533 1 47611 - + id 1 47555 @@ -4669,7 +4556,7 @@ false Zulu 1 403 - + rid 47630 10534 @@ -4679,7 +4566,7 @@ false Zulu 100 pg_catalog - + rid 1 47608 @@ -4690,26 +4577,26 @@ false Zulu 100 pg_catalog - + deleted_at 47567 10522 403 - + 1 47556 1 10521 47555 - + 1 47609 10527 47608 - + nextval('paperclip_sticker_packs_id_seq'::regclass) 1 1 @@ -4718,56 +4605,49 @@ false Zulu 47568 20 - + 2 10523 timestamp with time zone|0s 1184 - + 3 10523 timestamp with time zone|0s 1184 - + 4 10523 timestamp with time zone|0s 1184 - + 5 10523 text|0s 25 - + 6 10523 text|0s 25 - + 7 10523 text|0s 25 - + 8 10523 bigint|0s 20 - - account_id - 47577 - 10523 - 1 - 47539 - - + id 1 47575 @@ -4776,20 +4656,20 @@ false Zulu 1 403 - + deleted_at 47582 10524 403 - + 1 47576 1 10523 47575 - + nextval('paperclip_stickers_id_seq'::regclass) 1 1 @@ -4798,62 +4678,62 @@ false Zulu 47583 20 - + 2 10525 timestamp with time zone|0s 1184 - + 3 10525 timestamp with time zone|0s 1184 - + 4 10525 timestamp with time zone|0s 1184 - + 5 10525 text|0s 25 - + 6 10525 text|0s 25 - + 7 10525 bigint|0s 20 - + 8 10525 bigint|0s 20 - + 9 10525 bigint|0s 20 - + attachment_id 47592 10525 1 47549 - + pack_id 47602 cascade @@ -4861,14 +4741,7 @@ false Zulu 1 47569 - - account_id - 47597 - 10525 - 1 - 47539 - - + id 1 47590 @@ -4877,13 +4750,13 @@ false Zulu 1 403 - + deleted_at 47607 10526 403 - + 1 47591 1 diff --git a/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea/storage_v2/_src_/database/hy_paperclip.LrVPOQ/schema/public.abK9xQ.meta b/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea/storage_v2/_src_/database/hy_paperclip.LrVPOQ/schema/public.abK9xQ.meta index 84cfd84..14da328 100644 --- a/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea/storage_v2/_src_/database/hy_paperclip.LrVPOQ/schema/public.abK9xQ.meta +++ b/.idea/dataSources/bac83d8a-c619-4680-a07f-6674b93fbfea/storage_v2/_src_/database/hy_paperclip.LrVPOQ/schema/public.abK9xQ.meta @@ -1,2 +1,2 @@ #n:public -! [10537, 0, null, null, -2147483648, -2147483648] +! [11316, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 17f36d2..d8b54bc 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,22 +4,20 @@
- + + + + - - - - - - - - - - + + + + + - + - @@ -156,7 +153,8 @@ - true diff --git a/pkg/internal/gap/server.go b/pkg/internal/gap/server.go index 9fe5876..7cccb30 100644 --- a/pkg/internal/gap/server.go +++ b/pkg/internal/gap/server.go @@ -28,7 +28,7 @@ func InitializeToNexus() error { Type: "uc", Label: "Paperclip", GrpcAddr: grpcOutbound, - HttpAddr: lo.ToPtr("http://" + httpOutbound), + HttpAddr: lo.ToPtr("http://" + httpOutbound + "/api"), }) if err == nil { go func() { diff --git a/pkg/internal/server/api/attachments_api.go b/pkg/internal/server/api/attachments_api.go index 6bd08e2..7bba3ec 100644 --- a/pkg/internal/server/api/attachments_api.go +++ b/pkg/internal/server/api/attachments_api.go @@ -82,7 +82,7 @@ func getAttachmentMeta(c *fiber.Ctx) error { func updateAttachmentMeta(c *fiber.Ctx) error { id, _ := c.ParamsInt("id", 0) - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) var data struct { Alternative string `json:"alt"` @@ -112,7 +112,7 @@ func updateAttachmentMeta(c *fiber.Ctx) error { func deleteAttachment(c *fiber.Ctx) error { 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)) if err != nil { diff --git a/pkg/internal/server/api/index_api.go b/pkg/internal/server/api/index_api.go index 2f8d41e..3200d91 100644 --- a/pkg/internal/server/api/index_api.go +++ b/pkg/internal/server/api/index_api.go @@ -81,7 +81,7 @@ func listAttachment(c *fiber.Ctx) error { if needQuery { 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()) } diff --git a/pkg/internal/server/api/pools_api.go b/pkg/internal/server/api/pools_api.go index 70ce8df..b1eff76 100644 --- a/pkg/internal/server/api/pools_api.go +++ b/pkg/internal/server/api/pools_api.go @@ -27,7 +27,7 @@ func getPool(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 { Alias string `json:"alias" validate:"required"` @@ -56,7 +56,7 @@ func createPool(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 { Alias string `json:"alias" validate:"required"` @@ -88,7 +88,7 @@ func updatePool(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") pool, err := services.GetAttachmentPoolWithUser(uint(id), user.ID) diff --git a/pkg/internal/server/api/sticker_packs_api.go b/pkg/internal/server/api/sticker_packs_api.go index a179bd3..323c243 100644 --- a/pkg/internal/server/api/sticker_packs_api.go +++ b/pkg/internal/server/api/sticker_packs_api.go @@ -55,7 +55,7 @@ func getStickerPack(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 { 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 { - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) var data struct { 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 { - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) id, _ := c.ParamsInt("packId", 0) pack, err := services.GetStickerPackWithUser(uint(id), user.ID) diff --git a/pkg/internal/server/api/stickers_api.go b/pkg/internal/server/api/stickers_api.go index b334f8a..22fd828 100644 --- a/pkg/internal/server/api/stickers_api.go +++ b/pkg/internal/server/api/stickers_api.go @@ -80,7 +80,7 @@ func getSticker(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 { 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 { - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) var data struct { 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 { - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) id, _ := c.ParamsInt("stickerId", 0) sticker, err := services.GetStickerWithUser(uint(id), user.ID) diff --git a/pkg/internal/server/api/up_direct_api.go b/pkg/internal/server/api/up_direct_api.go index 5fb6e3b..1c84a1a 100644 --- a/pkg/internal/server/api/up_direct_api.go +++ b/pkg/internal/server/api/up_direct_api.go @@ -12,7 +12,7 @@ import ( ) func createAttachmentDirectly(c *fiber.Ctx) error { - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) poolAlias := c.FormValue("pool") diff --git a/pkg/internal/server/api/up_multipart_api.go b/pkg/internal/server/api/up_multipart_api.go index 222dd57..a004f48 100644 --- a/pkg/internal/server/api/up_multipart_api.go +++ b/pkg/internal/server/api/up_multipart_api.go @@ -13,7 +13,7 @@ import ( ) func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error { - user := c.Locals("nex_user").(sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) var data struct { Pool string `json:"pool" validate:"required"` @@ -69,7 +69,7 @@ func createAttachmentMultipartPlaceholder(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") cid := c.Params("chunk") diff --git a/pkg/internal/services/attachments.go b/pkg/internal/services/attachments.go index 21de432..59787fe 100644 --- a/pkg/internal/services/attachments.go +++ b/pkg/internal/services/attachments.go @@ -33,7 +33,7 @@ func GetAttachmentByID(id uint) (models.Attachment, error) { var attachment models.Attachment if err := database.C. Where("id = ?", id). - Preload("Pool").Preload("Account"). + Preload("Pool"). First(&attachment).Error; err != nil { return attachment, err } else { @@ -59,7 +59,7 @@ func GetAttachmentByRID(rid string) (models.Attachment, error) { var attachment models.Attachment if err := database.C.Where(models.Attachment{ Rid: rid, - }).Preload("Pool").Preload("Account").First(&attachment).Error; err != nil { + }).Preload("Pool").First(&attachment).Error; err != nil { return attachment, err } else { 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.Rid = RandString(16) attachment.Size = file.Size @@ -146,7 +146,7 @@ func NewAttachmentMetadata(tx *gorm.DB, user sec.UserInfo, file *multipart.FileH 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.Rid = RandString(16) attachment.IsUploaded = false diff --git a/pkg/internal/services/sticker_packs.go b/pkg/internal/services/sticker_packs.go index 3c36ec1..6381095 100644 --- a/pkg/internal/services/sticker_packs.go +++ b/pkg/internal/services/sticker_packs.go @@ -31,7 +31,7 @@ func ListStickerPackWithStickers(tx *gorm.DB, take, offset int) ([]models.Sticke 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{ Prefix: prefix, Name: name,