👽 Fix avatar cannot be updated due to attachment api updated
This commit is contained in:
parent
d2beaa67b4
commit
ed13d62110
1
go.mod
1
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
|
||||
|
2
go.sum
2
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=
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user