mirror of
https://github.com/yincongcyincong/wechat_chatter.git
synced 2026-07-15 10:26:52 +08:00
25 lines
668 B
Go
25 lines
668 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
func Download(rawMsg []byte) error {
|
|
downloadReq := new(DownloadRequest)
|
|
err := json.Unmarshal(rawMsg, downloadReq)
|
|
if err != nil {
|
|
Error("JSON解析失败", "err", err)
|
|
return err
|
|
}
|
|
|
|
Info("下载文件", "file_id", downloadReq.FileID, "media_len", len(downloadReq.Media), "cdn_url", downloadReq.CDNURL[:10])
|
|
if downloadReqInter, ok := userID2FileMsgMap.Load(downloadReq.CDNURL); ok {
|
|
beforeDownloadReq := downloadReqInter.(*DownloadRequest)
|
|
beforeDownloadReq.Media = append(beforeDownloadReq.Media, downloadReq.Media...)
|
|
} else {
|
|
userID2FileMsgMap.Store(downloadReq.CDNURL, downloadReq)
|
|
}
|
|
|
|
return nil
|
|
}
|