From 8e24ab924587530935d27742fe462ac275a9a4ce Mon Sep 17 00:00:00 2001 From: "DESKTOP-L8OUL9F\\gfl0034" <1003614916@qq.com> Date: Fri, 25 Sep 2026 00:03:55 +0800 Subject: [PATCH] =?UTF-8?q?chore(media):=20=E5=90=8C=E6=AD=A5=20docker/?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8E=20Bot=20=E9=99=84=E4=BB=B6=E5=BE=AE?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/config.yaml | 2 +- deploy/docker/config.docker.yaml | 27 +++++++++++++++++++++++ docs/media.md | 2 +- internal/module/squarebot/logic/attach.go | 6 ++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/configs/config.yaml b/configs/config.yaml index 8470e0c..22d646b 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -106,7 +106,7 @@ sms: username: "noreply@sparkmail.wyrs365.com" password: "gD9UNvSt5ilagfa1" from: "Spark IM " - aliyun_sms: + aliyun_sms: access_key_id: "" access_key_secret: "" sign_name: "" diff --git a/deploy/docker/config.docker.yaml b/deploy/docker/config.docker.yaml index 840c78f..bb2df65 100644 --- a/deploy/docker/config.docker.yaml +++ b/deploy/docker/config.docker.yaml @@ -99,6 +99,33 @@ object_storage: presign_ttl: 15m chat_expire_days: 365 +# App 主压缩;服务端用户检测 + 机器人入库前压缩(视频需镜像内 ffmpeg)。 +media: + enabled: true + user_reject: false + bot_compress: true + image_max_edge: 1080 + video_max_edge: 720 + avatar_max_edge: 200 + image_max_bytes: 10485760 + video_max_bytes: 104857600 + avatar_max_bytes: 2097152 + jpeg_quality: 85 + video_crf: 23 + ffmpeg_path: "ffmpeg" + +square_bot: + enabled: true + interval: 5m + ttl: 360h + bot_indexes: [] + feeds: + - "https://feeds.bbci.co.uk/news/world/rss.xml" + - "https://www.theguardian.com/world/rss" + - "https://feeds.npr.org/1004/rss.xml" + - "https://www.aljazeera.com/xml/rss/all.xml" + - "https://rss.nytimes.com/services/xml/rss/nyt/World.xml" + sms: smtp: host: "smtpdm-ap-southeast-1.aliyuncs.com" diff --git a/docs/media.md b/docs/media.md index 5ea1d2a..9f05f88 100644 --- a/docs/media.md +++ b/docs/media.md @@ -24,7 +24,7 @@ | 时机 | 位置 | 行为 | |------|------|------| -| RSS 配图 | `squarebot` Tick → `attachMedia` → `MediaCompressor.FetchImage` → `objectstore.Put` | 下载后压到 ≤1080,再写入 `perm/square/image/` | +| RSS 配图 | `squarebot` Tick → `attachMedia` → `FetchImage` → `objectstore.PutLarge` | 下载后压到 ≤1080,再写入 `perm/square/image/` | | 机器人视频路径 | `PrepareVideoAsset` / `FetchVideo` | ffmpeg 压到 ≤720(部署需 `ffmpeg`) | | 机器人头像 | `FetchAvatar` / `PrepareBotAvatar` | ≤200×200 | diff --git a/internal/module/squarebot/logic/attach.go b/internal/module/squarebot/logic/attach.go index 1cdbd28..76fa30a 100644 --- a/internal/module/squarebot/logic/attach.go +++ b/internal/module/squarebot/logic/attach.go @@ -48,7 +48,11 @@ func (s *Service) attachMedia(ctx context.Context, item FeedItem) []*squareentit uploadentity.PurposeSquareImage, 0, reqctx.NewObjectName(), time.Now().UTC().Format("20060102"), ext, ) - if err := s.store.Put(ctx, key, asset.Data, asset.MIME); err != nil { + maxBytes := int(asset.Size) + 1 + if maxBytes < 1<<20 { + maxBytes = 1 << 20 + } + if err := s.store.PutLarge(ctx, key, asset.Data, asset.MIME, maxBytes); err != nil { s.log.Warn("squarebot put image", zap.String("key", key), zap.Error(err)) return nil }