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
Commit
c0c9b1f6
authored
Nov 30, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: realtime
parent
6da37549
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
1 deletions
+5
-1
middleware/auth.go
+1
-0
relay/common/relay_info.go
+3
-0
service/quota.go
+1
-1
No files found.
middleware/auth.go
View file @
c0c9b1f6
...
@@ -212,6 +212,7 @@ func TokenAuth() func(c *gin.Context) {
...
@@ -212,6 +212,7 @@ func TokenAuth() func(c *gin.Context) {
}
}
c
.
Set
(
"id"
,
token
.
UserId
)
c
.
Set
(
"id"
,
token
.
UserId
)
c
.
Set
(
"token_id"
,
token
.
Id
)
c
.
Set
(
"token_id"
,
token
.
Id
)
c
.
Set
(
"token_key"
,
token
.
Key
)
c
.
Set
(
"token_name"
,
token
.
Name
)
c
.
Set
(
"token_name"
,
token
.
Name
)
c
.
Set
(
"token_unlimited_quota"
,
token
.
UnlimitedQuota
)
c
.
Set
(
"token_unlimited_quota"
,
token
.
UnlimitedQuota
)
if
!
token
.
UnlimitedQuota
{
if
!
token
.
UnlimitedQuota
{
...
...
relay/common/relay_info.go
View file @
c0c9b1f6
...
@@ -14,6 +14,7 @@ type RelayInfo struct {
...
@@ -14,6 +14,7 @@ type RelayInfo struct {
ChannelType
int
ChannelType
int
ChannelId
int
ChannelId
int
TokenId
int
TokenId
int
TokenKey
string
UserId
int
UserId
int
Group
string
Group
string
TokenUnlimited
bool
TokenUnlimited
bool
...
@@ -58,6 +59,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
...
@@ -58,6 +59,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
channelId
:=
c
.
GetInt
(
"channel_id"
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
tokenId
:=
c
.
GetInt
(
"token_id"
)
tokenId
:=
c
.
GetInt
(
"token_id"
)
tokenKey
:=
c
.
GetString
(
"token_key"
)
userId
:=
c
.
GetInt
(
"id"
)
userId
:=
c
.
GetInt
(
"id"
)
group
:=
c
.
GetString
(
"group"
)
group
:=
c
.
GetString
(
"group"
)
tokenUnlimited
:=
c
.
GetBool
(
"token_unlimited_quota"
)
tokenUnlimited
:=
c
.
GetBool
(
"token_unlimited_quota"
)
...
@@ -73,6 +75,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
...
@@ -73,6 +75,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
ChannelType
:
channelType
,
ChannelType
:
channelType
,
ChannelId
:
channelId
,
ChannelId
:
channelId
,
TokenId
:
tokenId
,
TokenId
:
tokenId
,
TokenKey
:
tokenKey
,
UserId
:
userId
,
UserId
:
userId
,
Group
:
group
,
Group
:
group
,
TokenUnlimited
:
tokenUnlimited
,
TokenUnlimited
:
tokenUnlimited
,
...
...
service/quota.go
View file @
c0c9b1f6
...
@@ -22,7 +22,7 @@ func PreWssConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, usag
...
@@ -22,7 +22,7 @@ func PreWssConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, usag
return
err
return
err
}
}
token
,
err
:=
model
.
CacheGetTokenByKey
(
strings
.
TrimLeft
(
relayInfo
.
Api
Key
,
"sk-"
))
token
,
err
:=
model
.
CacheGetTokenByKey
(
strings
.
TrimLeft
(
relayInfo
.
Token
Key
,
"sk-"
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
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