From ed73b40bf5245a04497148f1bfa456634898f6fb Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 16 Nov 2024 01:45:20 +0800 Subject: [PATCH] :wastebasket: Remove account preload --- pkg/internal/services/calls.go | 4 ++-- pkg/internal/services/channel_members.go | 1 - pkg/internal/services/channels.go | 6 +++--- pkg/internal/services/events.go | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/internal/services/calls.go b/pkg/internal/services/calls.go index 1df79f6..c1c2e81 100644 --- a/pkg/internal/services/calls.go +++ b/pkg/internal/services/calls.go @@ -109,7 +109,7 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call, return call, err } else if err = database.C.Where(models.ChannelMember{ ChannelID: call.ChannelID, - }).Preload("Account").Find(&members).Error; err == nil { + }).Find(&members).Error; err == nil { call, _ = GetCall(call.Channel, call.ID) var pendingUsers []uint64 for _, member := range members { @@ -169,7 +169,7 @@ func EndCall(call models.Call) (models.Call, error) { return call, err } else if err = database.C.Where(models.ChannelMember{ ChannelID: call.ChannelID, - }).Preload("Account").Find(&members).Error; err == nil { + }).Find(&members).Error; err == nil { call, _ = GetCall(call.Channel, call.ID) for _, member := range members { PushCommand(member.AccountID, nex.WebSocketPackage{ diff --git a/pkg/internal/services/channel_members.go b/pkg/internal/services/channel_members.go index 5c0504f..4127372 100644 --- a/pkg/internal/services/channel_members.go +++ b/pkg/internal/services/channel_members.go @@ -20,7 +20,6 @@ func ListChannelMember(channelId uint) ([]models.ChannelMember, error) { if err := database.C. Where(&models.ChannelMember{ChannelID: channelId}). - Preload("Account"). Find(&members).Error; err != nil { return members, err } diff --git a/pkg/internal/services/channels.go b/pkg/internal/services/channels.go index 95dd765..1bbefa4 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("Account").Preload("Realm") + tx := database.C.Where("id = ?", id).Preload("Realm") 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("Account").Preload("Realm") + tx := database.C.Where(models.Channel{Alias: alias}).Preload("Realm") 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("Account").Preload("Realm") + tx := database.C.Preload("Realm") tx = tx.Where("id IN ? OR is_public = true", idRange) if len(realmId) > 0 { tx = tx.Where("realm_id = ?", realmId) diff --git a/pkg/internal/services/events.go b/pkg/internal/services/events.go index bdf99e2..5c37255 100644 --- a/pkg/internal/services/events.go +++ b/pkg/internal/services/events.go @@ -77,7 +77,7 @@ func NewEvent(event models.Event) (models.Event, error) { return event, err } else if err = database.C.Where(models.ChannelMember{ ChannelID: event.ChannelID, - }).Preload("Account").Find(&members).Error; err != nil { + }).Find(&members).Error; err != nil { // Couldn't get channel members, skip notifying return event, nil }