chore(media): 同步 docker/配置与 Bot 附件微调

This commit is contained in:
DESKTOP-L8OUL9F\gfl0034 2026-09-25 00:03:55 +08:00
parent 59c73169e1
commit 8e24ab9245
4 changed files with 34 additions and 3 deletions

View File

@ -106,7 +106,7 @@ sms:
username: "noreply@sparkmail.wyrs365.com"
password: "gD9UNvSt5ilagfa1"
from: "Spark IM <noreply@sparkmail.wyrs365.com>"
aliyun_sms:
aliyun_sms:
access_key_id: ""
access_key_secret: ""
sign_name: ""

View File

@ -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"

View File

@ -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 |

View File

@ -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
}