diff --git a/pkg/internal/http/api/channel_members_api.go b/pkg/internal/http/api/channel_members_api.go index edb2379..0668fb6 100644 --- a/pkg/internal/http/api/channel_members_api.go +++ b/pkg/internal/http/api/channel_members_api.go @@ -206,7 +206,7 @@ func joinChannel(c *fiber.Ctx) error { var channel models.Channel if err := database.C.Where(&models.Channel{ Alias: alias, - }).Preload("Realm").First(&channel).Error; err != nil { + }).First(&channel).Error; err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) } else if _, _, err := services.GetAvailableChannel(channel.ID, user); err == nil { return fiber.NewError(fiber.StatusBadRequest, "you already joined the channel") diff --git a/pkg/internal/services/channels.go b/pkg/internal/services/channels.go index 1bbefa4..9706007 100644 --- a/pkg/internal/services/channels.go +++ b/pkg/internal/services/channels.go @@ -92,7 +92,7 @@ func GetChannelAliasAvailability(alias string) error { func GetChannel(id uint) (models.Channel, error) { var channel models.Channel - tx := database.C.Where("id = ?", id).Preload("Realm") + tx := database.C.Where("id = ?", id) tx = PreloadDirectChannelMembers(tx) if err := tx.First(&channel).Error; err != nil { return channel, err @@ -103,7 +103,7 @@ func GetChannel(id uint) (models.Channel, error) { func GetChannelWithAlias(alias string, realmId ...uint) (models.Channel, error) { var channel models.Channel - tx := database.C.Where(models.Channel{Alias: alias}).Preload("Realm") + tx := database.C.Where(models.Channel{Alias: alias}) if len(realmId) > 0 { tx = tx.Where("realm_id = ?", realmId) } else { @@ -178,7 +178,7 @@ func ListChannel(user *authm.Account, realmId ...uint) ([]models.Channel, error) } var channels []models.Channel - tx := database.C.Preload("Realm") + tx := database.C tx = tx.Where("id IN ? OR is_public = true", idRange) if len(realmId) > 0 { tx = tx.Where("realm_id = ?", realmId) @@ -195,7 +195,7 @@ func ListChannel(user *authm.Account, realmId ...uint) ([]models.Channel, error) func ListChannelWithUser(user authm.Account, realmId ...uint) ([]models.Channel, error) { var channels []models.Channel - tx := database.C.Where(&models.Channel{AccountID: user.ID}).Preload("Realm") + tx := database.C.Where(&models.Channel{AccountID: user.ID}) if len(realmId) > 0 { tx = tx.Where("realm_id = ?", realmId) } @@ -222,7 +222,7 @@ func ListAvailableChannel(tx *gorm.DB, user authm.Account, realmId ...uint) ([]m return item.ChannelID }) - tx = tx.Preload("Realm").Where("id IN ?", idx) + tx = tx.Where("id IN ?", idx) if len(realmId) > 0 { tx = tx.Where("realm_id = ?", realmId) } else {