From ed13d621109d0bd2a3c080292f18219fd379e9c5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 31 Jul 2024 14:16:13 +0800 Subject: [PATCH] :alien: Fix avatar cannot be updated due to attachment api updated --- go.mod | 1 - go.sum | 2 -- pkg/internal/server/api/avatar_api.go | 28 --------------------------- 3 files changed, 31 deletions(-) diff --git a/go.mod b/go.mod index 7815bad..51ed962 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ toolchain go1.22.1 require ( git.solsynth.dev/hydrogen/dealer v0.0.0-20240721055146-d74cdddbaf49 - git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 github.com/go-playground/validator/v10 v10.17.0 github.com/gofiber/fiber/v2 v2.52.4 github.com/golang-jwt/jwt/v5 v5.2.0 diff --git a/go.sum b/go.sum index dee0fc9..53ebc75 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ git.solsynth.dev/hydrogen/dealer v0.0.0-20240721055146-d74cdddbaf49 h1:DMmCBcnCO0qcER/p4EQ04CmWleb4YI3Br6QK5F8Q628= git.solsynth.dev/hydrogen/dealer v0.0.0-20240721055146-d74cdddbaf49/go.mod h1:IZd94qZZIj+MO9EqjGDqnAD9nWurlNPyhVPKemAY5lw= -git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 h1:40BUsQMNXjqHyytkyF9py1HjTAWlRgO6R57YXUrHNy4= -git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745/go.mod h1:FsQGSLTl0gvo+9Jmbot02S72suyF9tFTrzDj70Xhifo= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= diff --git a/pkg/internal/server/api/avatar_api.go b/pkg/internal/server/api/avatar_api.go index e6105c6..74e1a40 100644 --- a/pkg/internal/server/api/avatar_api.go +++ b/pkg/internal/server/api/avatar_api.go @@ -1,17 +1,11 @@ package api import ( - "context" - "fmt" - "git.solsynth.dev/hydrogen/dealer/pkg/hyper" - "git.solsynth.dev/hydrogen/paperclip/pkg/proto" "git.solsynth.dev/hydrogen/passport/pkg/internal/database" - "git.solsynth.dev/hydrogen/passport/pkg/internal/gap" "git.solsynth.dev/hydrogen/passport/pkg/internal/models" "git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts" "git.solsynth.dev/hydrogen/passport/pkg/internal/services" "github.com/gofiber/fiber/v2" - "github.com/samber/lo" ) func setAvatar(c *fiber.Ctx) error { @@ -28,17 +22,6 @@ func setAvatar(c *fiber.Ctx) error { return err } - pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeFileProvider) - if err != nil { - return fiber.NewError(fiber.StatusInternalServerError, "attachments services was not available") - } - if _, err := proto.NewAttachmentsClient(pc).CheckAttachmentExists(context.Background(), &proto.AttachmentLookupRequest{ - Id: lo.ToPtr(uint64(data.AttachmentID)), - Usage: lo.ToPtr("p.avatar"), - }); err != nil { - return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("avatar was not found in repository: %v", err)) - } - user.Avatar = &data.AttachmentID if err := database.C.Save(&user).Error; err != nil { @@ -64,17 +47,6 @@ func setBanner(c *fiber.Ctx) error { return err } - pc, err := gap.H.GetServiceGrpcConn(hyper.ServiceTypeFileProvider) - if err != nil { - return fiber.NewError(fiber.StatusInternalServerError, "attachments services was not available") - } - if _, err := proto.NewAttachmentsClient(pc).CheckAttachmentExists(context.Background(), &proto.AttachmentLookupRequest{ - Id: lo.ToPtr(uint64(data.AttachmentID)), - Usage: lo.ToPtr("p.banner"), - }); err != nil { - return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("banner was not found in repository: %v", err)) - } - user.Banner = &data.AttachmentID if err := database.C.Save(&user).Error; err != nil {