diff --git a/pkg/server/channel_members_api.go b/pkg/server/channel_members_api.go index abdd8c7..d513d0b 100644 --- a/pkg/server/channel_members_api.go +++ b/pkg/server/channel_members_api.go @@ -135,7 +135,7 @@ func removeChannelMember(c *fiber.Ctx) error { } } -func editChannelMembership(c *fiber.Ctx) error { +func editMyChannelMembership(c *fiber.Ctx) error { user := c.Locals("principal").(models.Account) alias := c.Params("channel") @@ -148,7 +148,13 @@ func editChannelMembership(c *fiber.Ctx) error { return err } - channel, err := services.GetChannelWithAlias(alias) + var err error + var channel models.Channel + if val, ok := c.Locals("realm").(models.Realm); ok { + channel, err = services.GetChannelWithAlias(alias, val.ID) + } else { + channel, err = services.GetChannelWithAlias(alias) + } if err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) } diff --git a/pkg/server/startup.go b/pkg/server/startup.go index ea453ea..9117083 100644 --- a/pkg/server/startup.go +++ b/pkg/server/startup.go @@ -80,8 +80,8 @@ func NewServer() { channels.Delete("/:channelId", authMiddleware, deleteChannel) channels.Get("/:channel/members", listChannelMembers) - channels.Put("/:channel/members/me", authMiddleware, editChannelMembership) channels.Get("/:channel/members/me", authMiddleware, getMyChannelMembership) + channels.Put("/:channel/members/me", authMiddleware, editMyChannelMembership) channels.Post("/:channel/members", authMiddleware, addChannelMember) channels.Post("/:channel/members/me", authMiddleware, joinChannel) channels.Delete("/:channel/members", authMiddleware, removeChannelMember)