Global wide channels api

This commit is contained in:
2025-02-22 16:22:08 +08:00
parent a8dbcfdb05
commit 0756806f20
3 changed files with 37 additions and 2 deletions

View File

@ -228,7 +228,9 @@ func ListChannelWithUser(user authm.Account, realmId ...uint) ([]models.Channel,
var channels []models.Channel
tx := database.C.Where(&models.Channel{AccountID: user.ID})
if len(realmId) > 0 {
tx = tx.Where("realm_id = ?", realmId)
if realmId[0] != 0 {
tx = tx.Where("realm_id = ?", realmId)
}
}
tx = PreloadDirectChannelMembers(tx)
@ -255,7 +257,9 @@ func ListAvailableChannel(tx *gorm.DB, user authm.Account, realmId ...uint) ([]m
tx = tx.Where("id IN ?", idx)
if len(realmId) > 0 {
tx = tx.Where("realm_id = ?", realmId)
if realmId[0] != 0 {
tx = tx.Where("realm_id = ?", realmId)
}
} else {
tx = tx.Where("realm_id IS NULL")
}