fix(feishu): use HTTP client with timeout for external image downloads
Replaced http.DefaultClient with a client that has a 30-second timeout to prevent hanging on unresponsive external URLs. Generated with Crush Assisted-by: GLM-5 via Crush <crush@charm.land>
This commit is contained in:
parent
40e5510b77
commit
efd67355e8
1 changed files with 4 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
lark "github.com/larksuite/oapi-sdk-go/v3"
|
lark "github.com/larksuite/oapi-sdk-go/v3"
|
||||||
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
|
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
|
||||||
|
|
@ -702,8 +703,9 @@ func (c *FeishuChannel) downloadExternalImage(
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download image
|
// Download image with timeout
|
||||||
resp, err := http.DefaultClient.Do(req)
|
client := &http.Client{Timeout: 30 * time.Second}
|
||||||
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorCF("feishu", "Failed to download external image", map[string]any{
|
logger.ErrorCF("feishu", "Failed to download external image", map[string]any{
|
||||||
"url": imageURL,
|
"url": imageURL,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue