From 485f72ededeaaaffdc045e697b5d357372537328 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 5 May 2024 22:12:40 +0800 Subject: [PATCH] :bug: Fix on cannot get messages history when channel related realm --- pkg/server/messages_api.go | 8 +++++++- settings.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/server/messages_api.go b/pkg/server/messages_api.go index 4a4653d..ebdf2e3 100644 --- a/pkg/server/messages_api.go +++ b/pkg/server/messages_api.go @@ -14,7 +14,13 @@ func listMessage(c *fiber.Ctx) error { offset := c.QueryInt("offset", 0) alias := c.Params("channel") - 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()) } else if _, _, err := services.GetAvailableChannel(channel.ID, user); err != nil { diff --git a/settings.toml b/settings.toml index 45c8bfb..c18fa49 100644 --- a/settings.toml +++ b/settings.toml @@ -10,7 +10,7 @@ secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi" content = "uploads" [debug] -database = false +database = true print_routes = false [identity]