fix(linter): fix ci lint err
This commit is contained in:
parent
c3631d84ba
commit
11b6b10d59
3 changed files with 17 additions and 12 deletions
|
|
@ -216,7 +216,10 @@ func detectWeComFiletype(data []byte) (string, string) {
|
||||||
return normalizeWeComContentType(kind.MIME.Value), ext
|
return normalizeWeComContentType(kind.MIME.Value), ext
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectWeComMediaMetadata(data []byte, fallbackName, fallbackContentType, resourceURL, contentDisposition string) (string, string) {
|
func detectWeComMediaMetadata(
|
||||||
|
data []byte,
|
||||||
|
fallbackName, fallbackContentType, resourceURL, contentDisposition string,
|
||||||
|
) (string, string) {
|
||||||
filename := candidateWeComFilename(resourceURL, contentDisposition, fallbackName)
|
filename := candidateWeComFilename(resourceURL, contentDisposition, fallbackName)
|
||||||
if filename == "" {
|
if filename == "" {
|
||||||
filename = "media"
|
filename = "media"
|
||||||
|
|
@ -717,7 +720,7 @@ func (c *WeComChannel) uploadOutboundMedia(
|
||||||
if end > len(data) {
|
if end > len(data) {
|
||||||
end = len(data)
|
end = len(data)
|
||||||
}
|
}
|
||||||
if err := c.sendCommand(wecomCommand{
|
sendErr := c.sendCommand(wecomCommand{
|
||||||
Cmd: wecomCmdUploadMediaChunk,
|
Cmd: wecomCmdUploadMediaChunk,
|
||||||
Headers: wecomHeaders{ReqID: randomID(10)},
|
Headers: wecomHeaders{ReqID: randomID(10)},
|
||||||
Body: wecomUploadMediaChunkBody{
|
Body: wecomUploadMediaChunkBody{
|
||||||
|
|
@ -725,8 +728,9 @@ func (c *WeComChannel) uploadOutboundMedia(
|
||||||
ChunkIndex: idx,
|
ChunkIndex: idx,
|
||||||
Base64Data: base64.StdEncoding.EncodeToString(data[offset:end]),
|
Base64Data: base64.StdEncoding.EncodeToString(data[offset:end]),
|
||||||
},
|
},
|
||||||
}, wecomUploadTimeout); err != nil {
|
}, wecomUploadTimeout)
|
||||||
return nil, err
|
if sendErr != nil {
|
||||||
|
return nil, sendErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -734,11 +734,6 @@ func (c *WeComChannel) sendCommandAck(cmd wecomCommand, timeout time.Duration) (
|
||||||
return c.writeCurrentAck(cmd, timeout)
|
return c.writeCurrentAck(cmd, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *WeComChannel) writeCurrent(cmd wecomCommand, timeout time.Duration) error {
|
|
||||||
_, err := c.writeCurrentAck(cmd, timeout)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *WeComChannel) writeCurrentAck(cmd wecomCommand, timeout time.Duration) (wecomEnvelope, error) {
|
func (c *WeComChannel) writeCurrentAck(cmd wecomCommand, timeout time.Duration) (wecomEnvelope, error) {
|
||||||
c.connMu.Lock()
|
c.connMu.Lock()
|
||||||
conn := c.conn
|
conn := c.conn
|
||||||
|
|
@ -788,7 +783,12 @@ func (c *WeComChannel) writeAndWaitAck(
|
||||||
select {
|
select {
|
||||||
case env := <-waitCh:
|
case env := <-waitCh:
|
||||||
if env.ErrCode != 0 {
|
if env.ErrCode != 0 {
|
||||||
return wecomEnvelope{}, fmt.Errorf("%w: wecom errcode=%d errmsg=%s", channels.ErrTemporary, env.ErrCode, env.ErrMsg)
|
return wecomEnvelope{}, fmt.Errorf(
|
||||||
|
"%w: wecom errcode=%d errmsg=%s",
|
||||||
|
channels.ErrTemporary,
|
||||||
|
env.ErrCode,
|
||||||
|
env.ErrMsg,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return env, nil
|
return env, nil
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
|
|
|
||||||
|
|
@ -285,8 +285,9 @@ func TestSendMedia_UsesTurnImageAndFinishesStream(t *testing.T) {
|
||||||
StreamID: "stream-1",
|
StreamID: "stream-1",
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
})
|
})
|
||||||
if err := ch.routes.Put("chat-1", "req-1", 1, time.Hour); err != nil {
|
putErr := ch.routes.Put("chat-1", "req-1", 1, time.Hour)
|
||||||
t.Fatalf("Put() error = %v", err)
|
if putErr != nil {
|
||||||
|
t.Fatalf("Put() error = %v", putErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
var commands []wecomCommand
|
var commands []wecomCommand
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue