🐛 Bug fixes

This commit is contained in:
2024-06-01 10:43:21 +08:00
parent d03ad71064
commit 23450c0690
3 changed files with 16 additions and 17 deletions

View File

@ -26,22 +26,22 @@ func getChannel(c *fiber.Ctx) error {
return c.JSON(channel)
}
func getChannelAvailability(c *fiber.Ctx) error {
func getChannelIdentity(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
alias := c.Params("channel")
var err error
var channel models.Channel
var member models.ChannelMember
if val, ok := c.Locals("realm").(models.Realm); ok {
channel, _, err = services.GetAvailableChannelWithAlias(alias, user, val.ID)
_, member, err = services.GetAvailableChannelWithAlias(alias, user, val.ID)
} else {
channel, _, err = services.GetAvailableChannelWithAlias(alias, user)
_, member, err = services.GetAvailableChannelWithAlias(alias, user)
}
if err != nil {
return c.Status(fiber.StatusForbidden).JSON(channel)
return c.SendStatus(fiber.StatusForbidden)
}
return c.JSON(channel)
return c.JSON(member)
}
func listChannel(c *fiber.Ctx) error {

View File

@ -72,7 +72,7 @@ func NewServer() {
channels.Get("/me", authMiddleware, listOwnedChannel)
channels.Get("/me/available", authMiddleware, listAvailableChannel)
channels.Get("/:channel", getChannel)
channels.Get("/:channel/availability", authMiddleware, getChannelAvailability)
channels.Get("/:channel/me", authMiddleware, getChannelIdentity)
channels.Post("/", authMiddleware, createChannel)
channels.Post("/dm", authMiddleware, createDirectChannel)