return url when updating the avatar
parent
8a55703b58
commit
db42cfcda3
|
@ -45,3 +45,8 @@ type UserSession struct {
|
||||||
LastUsed int64
|
LastUsed int64
|
||||||
CreatedAt int64
|
CreatedAt int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// swagger:model UpdateUserAvatarResponse
|
||||||
|
type UpdateUserAvatarResponse struct {
|
||||||
|
AvatarUrl string
|
||||||
|
}
|
||||||
|
|
|
@ -60,8 +60,6 @@ func UpdateAvatar(c *fiber.Ctx) error {
|
||||||
return c.SendStatus(fiber.StatusBadRequest)
|
return c.SendStatus(fiber.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Println("size", file.Size, "header", file.Header, "filename", file.Filename)
|
|
||||||
|
|
||||||
if file.Size > image.MaxAvatarSize {
|
if file.Size > image.MaxAvatarSize {
|
||||||
return c.SendStatus(fiber.StatusRequestEntityTooLarge)
|
return c.SendStatus(fiber.StatusRequestEntityTooLarge)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +78,8 @@ func UpdateAvatar(c *fiber.Ctx) error {
|
||||||
return c.SendStatus(fiber.StatusBadRequest)
|
return c.SendStatus(fiber.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
user := structs.User{Id: foundSession.UserId, AvatarUrl: utils.GetUserAvatarUrl(foundSession.UserId, fileName)}
|
avatarUrl := utils.GetUserAvatarUrl(foundSession.UserId, fileName)
|
||||||
|
user := structs.User{Id: foundSession.UserId, AvatarUrl: avatarUrl}
|
||||||
|
|
||||||
q = scylladb.Session.Query(scylladb.Users.Update("avatar_url")).BindStruct(user)
|
q = scylladb.Session.Query(scylladb.Users.Update("avatar_url")).BindStruct(user)
|
||||||
|
|
||||||
|
@ -89,5 +88,5 @@ func UpdateAvatar(c *fiber.Ctx) error {
|
||||||
return c.SendStatus(fiber.StatusInternalServerError)
|
return c.SendStatus(fiber.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.SendStatus(fiber.StatusOK)
|
return c.Status(fiber.StatusOK).JSON(structs.UpdateUserAvatarResponse{AvatarUrl: avatarUrl})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue