Separate list public channel

This commit is contained in:
2025-02-15 15:55:06 +08:00
parent 406eb9c93b
commit 2e18b2455b
3 changed files with 33 additions and 0 deletions

View File

@ -207,6 +207,23 @@ func ListChannel(user *authm.Account, realmId ...uint) ([]models.Channel, error)
return channels, nil
}
func ListChannelPublic(realmId ...uint) ([]models.Channel, error) {
var channels []models.Channel
tx := database.C
tx = tx.Where("is_public = true")
if len(realmId) > 0 {
tx = tx.Where("realm_id = ?", realmId)
}
tx = PreloadDirectChannelMembers(tx)
if err := tx.Find(&channels).Error; err != nil {
return channels, err
}
return channels, nil
}
func ListChannelWithUser(user authm.Account, realmId ...uint) ([]models.Channel, error) {
var channels []models.Channel
tx := database.C.Where(&models.Channel{AccountID: user.ID})