Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
3a2aecbc
authored
Apr 08, 2026
by
Calcium-Ion
Committed by
GitHub
Apr 08, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4123 from bbbugg/fix/enabled-api
fix(pricing): add filtering for pricing based on usable groups
parents
49648d8b
07843d78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
controller/pricing.go
+26
-0
No files found.
controller/pricing.go
View file @
3a2aecbc
package
controller
import
(
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/setting/ratio_setting"
...
...
@@ -8,6 +9,30 @@ import (
"github.com/gin-gonic/gin"
)
func
filterPricingByUsableGroups
(
pricing
[]
model
.
Pricing
,
usableGroup
map
[
string
]
string
)
[]
model
.
Pricing
{
if
len
(
pricing
)
==
0
{
return
pricing
}
if
len
(
usableGroup
)
==
0
{
return
[]
model
.
Pricing
{}
}
filtered
:=
make
([]
model
.
Pricing
,
0
,
len
(
pricing
))
for
_
,
item
:=
range
pricing
{
if
common
.
StringsContains
(
item
.
EnableGroup
,
"all"
)
{
filtered
=
append
(
filtered
,
item
)
continue
}
for
_
,
group
:=
range
item
.
EnableGroup
{
if
_
,
ok
:=
usableGroup
[
group
];
ok
{
filtered
=
append
(
filtered
,
item
)
break
}
}
}
return
filtered
}
func
GetPricing
(
c
*
gin
.
Context
)
{
pricing
:=
model
.
GetPricing
()
userId
,
exists
:=
c
.
Get
(
"id"
)
...
...
@@ -31,6 +56,7 @@ func GetPricing(c *gin.Context) {
}
usableGroup
=
service
.
GetUserUsableGroups
(
group
)
pricing
=
filterPricingByUsableGroups
(
pricing
,
usableGroup
)
// check groupRatio contains usableGroup
for
group
:=
range
ratio_setting
.
GetGroupRatioCopy
()
{
if
_
,
ok
:=
usableGroup
[
group
];
!
ok
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment