✨ Can check channel availability with API
This commit is contained in:
parent
eb78e93cb2
commit
d66b591f92
@ -25,6 +25,24 @@ func getChannel(c *fiber.Ctx) error {
|
||||
return c.JSON(channel)
|
||||
}
|
||||
|
||||
func getChannelAvailability(c *fiber.Ctx) error {
|
||||
user := c.Locals("principal").(models.Account)
|
||||
alias := c.Params("channel")
|
||||
|
||||
var err error
|
||||
var channel models.Channel
|
||||
if val, ok := c.Locals("realm").(models.Realm); ok {
|
||||
channel, _, err = services.GetAvailableChannelWithAlias(alias, user, val.ID)
|
||||
} else {
|
||||
channel, _, err = services.GetAvailableChannelWithAlias(alias, user)
|
||||
}
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusForbidden, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(channel)
|
||||
}
|
||||
|
||||
func listChannel(c *fiber.Ctx) error {
|
||||
var err error
|
||||
var channels []models.Channel
|
||||
|
@ -79,6 +79,7 @@ func NewServer() {
|
||||
{
|
||||
channels.Get("/", listChannel)
|
||||
channels.Get("/:channel", getChannel)
|
||||
channels.Get("/:channel/available", authMiddleware, getChannelAvailability)
|
||||
channels.Get("/me", authMiddleware, listOwnedChannel)
|
||||
channels.Get("/me/available", authMiddleware, listAvailableChannel)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user