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
c1b05d3b
authored
Feb 22, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: clean up unused code and improve error logging in adaptor and mjp modules
parent
bf03f277
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
20 deletions
+11
-20
controller/midjourney.go
+2
-2
relay/channel/task/suno/adaptor.go
+7
-16
service/task_polling.go
+2
-2
No files found.
controller/midjourney.go
View file @
c1b05d3b
...
@@ -105,13 +105,13 @@ func UpdateMidjourneyTaskBulk() {
...
@@ -105,13 +105,13 @@ func UpdateMidjourneyTaskBulk() {
}
}
responseBody
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
responseBody
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Get Task parse body error: %v"
,
err
))
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Get
Mjp
Task parse body error: %v"
,
err
))
continue
continue
}
}
var
responseItems
[]
dto
.
MidjourneyDto
var
responseItems
[]
dto
.
MidjourneyDto
err
=
json
.
Unmarshal
(
responseBody
,
&
responseItems
)
err
=
json
.
Unmarshal
(
responseBody
,
&
responseItems
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Get Task parse body error2: %v, body: %s"
,
err
,
string
(
responseBody
)))
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Get
Mjp
Task parse body error2: %v, body: %s"
,
err
,
string
(
responseBody
)))
continue
continue
}
}
resp
.
Body
.
Close
()
resp
.
Body
.
Close
()
...
...
relay/channel/task/suno/adaptor.go
View file @
c1b05d3b
...
@@ -2,12 +2,10 @@ package suno
...
@@ -2,12 +2,10 @@ package suno
import
(
import
(
"bytes"
"bytes"
"context"
"fmt"
"fmt"
"io"
"io"
"net/http"
"net/http"
"strings"
"strings"
"time"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/constant"
...
@@ -52,13 +50,13 @@ func (a *TaskAdaptor) ValidateRequestAndSetAction(c *gin.Context, info *relaycom
...
@@ -52,13 +50,13 @@ func (a *TaskAdaptor) ValidateRequestAndSetAction(c *gin.Context, info *relaycom
return
return
}
}
if
sunoRequest
.
ContinueClipId
!=
""
{
//
if sunoRequest.ContinueClipId != "" {
if
sunoRequest
.
TaskID
==
""
{
//
if sunoRequest.TaskID == "" {
taskErr
=
service
.
TaskErrorWrapperLocal
(
fmt
.
Errorf
(
"task id is empty"
),
"invalid_request"
,
http
.
StatusBadRequest
)
//
taskErr = service.TaskErrorWrapperLocal(fmt.Errorf("task id is empty"), "invalid_request", http.StatusBadRequest)
return
//
return
}
//
}
info
.
OriginTaskID
=
sunoRequest
.
TaskID
//
info.OriginTaskID = sunoRequest.TaskID
}
//
}
info
.
Action
=
action
info
.
Action
=
action
c
.
Set
(
"task_request"
,
sunoRequest
)
c
.
Set
(
"task_request"
,
sunoRequest
)
...
@@ -142,13 +140,6 @@ func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any, proxy
...
@@ -142,13 +140,6 @@ func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any, proxy
common
.
SysLog
(
fmt
.
Sprintf
(
"Get Task error: %v"
,
err
))
common
.
SysLog
(
fmt
.
Sprintf
(
"Get Task error: %v"
,
err
))
return
nil
,
err
return
nil
,
err
}
}
defer
req
.
Body
.
Close
()
// 设置超时时间
timeout
:=
time
.
Second
*
15
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
// 使用带有超时的 context 创建新的请求
req
=
req
.
WithContext
(
ctx
)
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
key
)
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
key
)
client
,
err
:=
service
.
GetHttpClientWithProxy
(
proxy
)
client
,
err
:=
service
.
GetHttpClientWithProxy
(
proxy
)
...
...
service/task_polling.go
View file @
c1b05d3b
...
@@ -206,13 +206,13 @@ func updateSunoTasks(ctx context.Context, channelId int, taskIds []string, taskM
...
@@ -206,13 +206,13 @@ func updateSunoTasks(ctx context.Context, channelId int, taskIds []string, taskM
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
responseBody
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
responseBody
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
common
.
SysLog
(
fmt
.
Sprintf
(
"Get Task parse body error: %v"
,
err
))
common
.
SysLog
(
fmt
.
Sprintf
(
"Get
Suno
Task parse body error: %v"
,
err
))
return
err
return
err
}
}
var
responseItems
dto
.
TaskResponse
[[]
dto
.
SunoDataResponse
]
var
responseItems
dto
.
TaskResponse
[[]
dto
.
SunoDataResponse
]
err
=
common
.
Unmarshal
(
responseBody
,
&
responseItems
)
err
=
common
.
Unmarshal
(
responseBody
,
&
responseItems
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Get Task parse body error2: %v, body: %s"
,
err
,
string
(
responseBody
)))
logger
.
LogError
(
ctx
,
fmt
.
Sprintf
(
"Get
Suno
Task parse body error2: %v, body: %s"
,
err
,
string
(
responseBody
)))
return
err
return
err
}
}
if
!
responseItems
.
IsSuccess
()
{
if
!
responseItems
.
IsSuccess
()
{
...
...
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