🐛 Bug fixes in update avatar

This commit is contained in:
2024-05-18 20:39:46 +08:00
parent fd5bbd732f
commit ee4f929d6c
3 changed files with 44 additions and 43 deletions

View File

@ -7,6 +7,7 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/passport/pkg/grpc"
"git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/passport/pkg/utils"
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
)
@ -15,7 +16,11 @@ func setAvatar(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
var data struct {
AttachmentID string `json:"attachment"`
AttachmentID string `json:"attachment" validate:"required"`
}
if err := utils.BindAndValidate(c, &data); err != nil {
return err
}
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
@ -36,8 +41,13 @@ func setAvatar(c *fiber.Ctx) error {
func setBanner(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
var data struct {
AttachmentID string `json:"attachment"`
AttachmentID string `json:"attachment" validate:"required"`
}
if err := utils.BindAndValidate(c, &data); err != nil {
return err
}
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{