mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-16 13:13:41 +08:00
✨ feat: Allow skip channel id
This commit is contained in:
@@ -108,16 +108,20 @@ func tokenAuth(c *gin.Context, key string) {
|
||||
c.Set("chat_cache", token.ChatCache)
|
||||
if len(parts) > 1 {
|
||||
if model.IsAdmin(token.UserId) {
|
||||
channelId := common.String2Int(parts[1])
|
||||
if channelId == 0 {
|
||||
abortWithMessage(c, http.StatusForbidden, "无效的渠道 Id")
|
||||
return
|
||||
if strings.HasPrefix(parts[1], "!") {
|
||||
channelId := common.String2Int(parts[1][1:])
|
||||
c.Set("skip_channel_id", channelId)
|
||||
} else {
|
||||
channelId := common.String2Int(parts[1])
|
||||
if channelId == 0 {
|
||||
abortWithMessage(c, http.StatusForbidden, "无效的渠道 Id")
|
||||
return
|
||||
}
|
||||
c.Set("specific_channel_id", channelId)
|
||||
if len(parts) == 3 && parts[2] == "ignore" {
|
||||
c.Set("specific_channel_id_ignore", true)
|
||||
}
|
||||
}
|
||||
c.Set("specific_channel_id", channelId)
|
||||
if len(parts) == 3 && parts[2] == "ignore" {
|
||||
c.Set("specific_channel_id_ignore", true)
|
||||
}
|
||||
|
||||
} else {
|
||||
abortWithMessage(c, http.StatusForbidden, "普通用户不支持指定渠道")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user