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
cb0d3d60
authored
Sep 14, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: settings
parent
523ee96b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
service/cf_worker.go
+6
-6
service/user_notify.go
+3
-3
service/webhook.go
+3
-3
No files found.
service/cf_worker.go
View file @
cb0d3d60
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
"one-api/common"
"one-api/common"
"one-api/setting"
"one-api/setting
/system_setting
"
"strings"
"strings"
)
)
...
@@ -21,14 +21,14 @@ type WorkerRequest struct {
...
@@ -21,14 +21,14 @@ type WorkerRequest struct {
// DoWorkerRequest 通过Worker发送请求
// DoWorkerRequest 通过Worker发送请求
func
DoWorkerRequest
(
req
*
WorkerRequest
)
(
*
http
.
Response
,
error
)
{
func
DoWorkerRequest
(
req
*
WorkerRequest
)
(
*
http
.
Response
,
error
)
{
if
!
setting
.
EnableWorker
()
{
if
!
s
ystem_s
etting
.
EnableWorker
()
{
return
nil
,
fmt
.
Errorf
(
"worker not enabled"
)
return
nil
,
fmt
.
Errorf
(
"worker not enabled"
)
}
}
if
!
setting
.
WorkerAllowHttpImageRequestEnabled
&&
!
strings
.
HasPrefix
(
req
.
URL
,
"https"
)
{
if
!
s
ystem_s
etting
.
WorkerAllowHttpImageRequestEnabled
&&
!
strings
.
HasPrefix
(
req
.
URL
,
"https"
)
{
return
nil
,
fmt
.
Errorf
(
"only support https url"
)
return
nil
,
fmt
.
Errorf
(
"only support https url"
)
}
}
workerUrl
:=
setting
.
WorkerUrl
workerUrl
:=
s
ystem_s
etting
.
WorkerUrl
if
!
strings
.
HasSuffix
(
workerUrl
,
"/"
)
{
if
!
strings
.
HasSuffix
(
workerUrl
,
"/"
)
{
workerUrl
+=
"/"
workerUrl
+=
"/"
}
}
...
@@ -43,11 +43,11 @@ func DoWorkerRequest(req *WorkerRequest) (*http.Response, error) {
...
@@ -43,11 +43,11 @@ func DoWorkerRequest(req *WorkerRequest) (*http.Response, error) {
}
}
func
DoDownloadRequest
(
originUrl
string
,
reason
...
string
)
(
resp
*
http
.
Response
,
err
error
)
{
func
DoDownloadRequest
(
originUrl
string
,
reason
...
string
)
(
resp
*
http
.
Response
,
err
error
)
{
if
setting
.
EnableWorker
()
{
if
s
ystem_s
etting
.
EnableWorker
()
{
common
.
SysLog
(
fmt
.
Sprintf
(
"downloading file from worker: %s, reason: %s"
,
originUrl
,
strings
.
Join
(
reason
,
", "
)))
common
.
SysLog
(
fmt
.
Sprintf
(
"downloading file from worker: %s, reason: %s"
,
originUrl
,
strings
.
Join
(
reason
,
", "
)))
req
:=
&
WorkerRequest
{
req
:=
&
WorkerRequest
{
URL
:
originUrl
,
URL
:
originUrl
,
Key
:
setting
.
WorkerValidKey
,
Key
:
s
ystem_s
etting
.
WorkerValidKey
,
}
}
return
DoWorkerRequest
(
req
)
return
DoWorkerRequest
(
req
)
}
else
{
}
else
{
...
...
service/user_notify.go
View file @
cb0d3d60
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"one-api/common"
"one-api/common"
"one-api/dto"
"one-api/dto"
"one-api/model"
"one-api/model"
"one-api/setting"
"one-api/setting
/system_setting
"
"strings"
"strings"
)
)
...
@@ -91,11 +91,11 @@ func sendBarkNotify(barkURL string, data dto.Notify) error {
...
@@ -91,11 +91,11 @@ func sendBarkNotify(barkURL string, data dto.Notify) error {
var
resp
*
http
.
Response
var
resp
*
http
.
Response
var
err
error
var
err
error
if
setting
.
EnableWorker
()
{
if
s
ystem_s
etting
.
EnableWorker
()
{
// 使用worker发送请求
// 使用worker发送请求
workerReq
:=
&
WorkerRequest
{
workerReq
:=
&
WorkerRequest
{
URL
:
finalURL
,
URL
:
finalURL
,
Key
:
setting
.
WorkerValidKey
,
Key
:
s
ystem_s
etting
.
WorkerValidKey
,
Method
:
http
.
MethodGet
,
Method
:
http
.
MethodGet
,
Headers
:
map
[
string
]
string
{
Headers
:
map
[
string
]
string
{
"User-Agent"
:
"OneAPI-Bark-Notify/1.0"
,
"User-Agent"
:
"OneAPI-Bark-Notify/1.0"
,
...
...
service/webhook.go
View file @
cb0d3d60
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
"fmt"
"fmt"
"net/http"
"net/http"
"one-api/dto"
"one-api/dto"
"one-api/setting"
"one-api/setting
/system_setting
"
"time"
"time"
)
)
...
@@ -56,11 +56,11 @@ func SendWebhookNotify(webhookURL string, secret string, data dto.Notify) error
...
@@ -56,11 +56,11 @@ func SendWebhookNotify(webhookURL string, secret string, data dto.Notify) error
var
req
*
http
.
Request
var
req
*
http
.
Request
var
resp
*
http
.
Response
var
resp
*
http
.
Response
if
setting
.
EnableWorker
()
{
if
s
ystem_s
etting
.
EnableWorker
()
{
// 构建worker请求数据
// 构建worker请求数据
workerReq
:=
&
WorkerRequest
{
workerReq
:=
&
WorkerRequest
{
URL
:
webhookURL
,
URL
:
webhookURL
,
Key
:
setting
.
WorkerValidKey
,
Key
:
s
ystem_s
etting
.
WorkerValidKey
,
Method
:
http
.
MethodPost
,
Method
:
http
.
MethodPost
,
Headers
:
map
[
string
]
string
{
Headers
:
map
[
string
]
string
{
"Content-Type"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
...
...
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