🗑️ Remove account preload

This commit is contained in:
LittleSheep 2024-11-16 01:45:20 +08:00
parent 2d05be679d
commit ed73b40bf5
4 changed files with 6 additions and 7 deletions

View File

@ -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{

View File

@ -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
}

View File

@ -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)

View File

@ -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
}