mirror of
https://github.com/versia-pub/versia-go.git
synced 2025-12-06 14:28:20 +01:00
29 lines
780 B
Go
29 lines
780 B
Go
package follow_handler
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/google/uuid"
|
|
"github.com/lysand-org/versia-go/internal/api_schema"
|
|
)
|
|
|
|
func (i *Handler) GetLysandFollow(c *fiber.Ctx) error {
|
|
parsedRequestedFollowID, err := uuid.Parse(c.Params("id"))
|
|
if err != nil {
|
|
return api_schema.ErrBadRequest(map[string]any{"reason": "Invalid follow ID"})
|
|
}
|
|
|
|
f, err := i.followService.GetFollow(c.UserContext(), parsedRequestedFollowID)
|
|
if err != nil {
|
|
i.log.Error(err, "Failed to query follow", "id", parsedRequestedFollowID)
|
|
|
|
return api_schema.ErrInternalServerError(map[string]any{"reason": "Failed to query follow"})
|
|
}
|
|
if f == nil {
|
|
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{
|
|
"error": "Follow not found",
|
|
})
|
|
}
|
|
|
|
return c.JSON(f.ToLysand())
|
|
}
|