Files
new-api/model/subscription_group.go
2026-04-09 22:31:14 +08:00

48 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"strings"
"github.com/QuantumNous/new-api/setting"
)
const PrefillGroupTypeSubscriptionGroup = "subscription_group"
func ListSubscriptionDedicatedGroups() ([]string, error) {
groups := setting.GetSubscriptionGroupsCopy()
result := make([]string, 0, len(groups))
for name := range groups {
name = strings.TrimSpace(name)
if name != "" {
result = append(result, name)
}
}
return result, nil
}
func GetSubscriptionDedicatedGroupSet() (map[string]struct{}, error) {
groups := setting.GetSubscriptionGroupsCopy()
result := make(map[string]struct{}, len(groups))
for name := range groups {
name = strings.TrimSpace(name)
if name != "" {
result[name] = struct{}{}
}
}
return result, nil
}
func IsSubscriptionDedicatedGroup(group string) (bool, error) {
group = strings.TrimSpace(group)
if group == "" {
return false, nil
}
return setting.IsSubscriptionGroup(group), nil
}
// 历史实现会把 allowed_consume_groups 自动种成 subscription_group导致"套餐允许消费分组"与
// "订阅专属分组"语义混淆。现保留该入口仅做兼容空操作,避免启动迁移时报错,并停止自动污染分组语义。
func EnsureSubscriptionDedicatedGroupsSeededFromPlans() error {
return nil
}