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
5fd74c34
authored
Sep 14, 2025
by
Calcium-Ion
Committed by
GitHub
Sep 14, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1799 from seefs001/fix/setting
fix: settings
parents
523ee96b
cb0d3d60
Hide 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 @
5fd74c34
...
...
@@ -6,7 +6,7 @@ import (
"fmt"
"net/http"
"one-api/common"
"one-api/setting"
"one-api/setting
/system_setting
"
"strings"
)
...
...
@@ -21,14 +21,14 @@ type WorkerRequest struct {
// DoWorkerRequest 通过Worker发送请求
func
DoWorkerRequest
(
req
*
WorkerRequest
)
(
*
http
.
Response
,
error
)
{
if
!
setting
.
EnableWorker
()
{
if
!
s
ystem_s
etting
.
EnableWorker
()
{
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"
)
}
workerUrl
:=
setting
.
WorkerUrl
workerUrl
:=
s
ystem_s
etting
.
WorkerUrl
if
!
strings
.
HasSuffix
(
workerUrl
,
"/"
)
{
workerUrl
+=
"/"
}
...
...
@@ -43,11 +43,11 @@ func DoWorkerRequest(req *WorkerRequest) (*http.Response, 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
,
", "
)))
req
:=
&
WorkerRequest
{
URL
:
originUrl
,
Key
:
setting
.
WorkerValidKey
,
Key
:
s
ystem_s
etting
.
WorkerValidKey
,
}
return
DoWorkerRequest
(
req
)
}
else
{
...
...
service/user_notify.go
View file @
5fd74c34
...
...
@@ -7,7 +7,7 @@ import (
"one-api/common"
"one-api/dto"
"one-api/model"
"one-api/setting"
"one-api/setting
/system_setting
"
"strings"
)
...
...
@@ -91,11 +91,11 @@ func sendBarkNotify(barkURL string, data dto.Notify) error {
var
resp
*
http
.
Response
var
err
error
if
setting
.
EnableWorker
()
{
if
s
ystem_s
etting
.
EnableWorker
()
{
// 使用worker发送请求
workerReq
:=
&
WorkerRequest
{
URL
:
finalURL
,
Key
:
setting
.
WorkerValidKey
,
Key
:
s
ystem_s
etting
.
WorkerValidKey
,
Method
:
http
.
MethodGet
,
Headers
:
map
[
string
]
string
{
"User-Agent"
:
"OneAPI-Bark-Notify/1.0"
,
...
...
service/webhook.go
View file @
5fd74c34
...
...
@@ -9,7 +9,7 @@ import (
"fmt"
"net/http"
"one-api/dto"
"one-api/setting"
"one-api/setting
/system_setting
"
"time"
)
...
...
@@ -56,11 +56,11 @@ func SendWebhookNotify(webhookURL string, secret string, data dto.Notify) error
var
req
*
http
.
Request
var
resp
*
http
.
Response
if
setting
.
EnableWorker
()
{
if
s
ystem_s
etting
.
EnableWorker
()
{
// 构建worker请求数据
workerReq
:=
&
WorkerRequest
{
URL
:
webhookURL
,
Key
:
setting
.
WorkerValidKey
,
Key
:
s
ystem_s
etting
.
WorkerValidKey
,
Method
:
http
.
MethodPost
,
Headers
:
map
[
string
]
string
{
"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