FT-WP-0001-T14: upload post images instead of linking them

The adapter fetches visual_url from an allowlisted host (https, image types,
10 MB cap, optional read token) and uploads it as multipart sendPhoto, so the
forge can close without breaking post images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 5457@bnt-lap001
Assistant-Session: 792bf84a-3783-4f5d-a811-cded61dd2012
This commit is contained in:
tegwick 2026-10-08 20:55:32 +02:00
parent e70c8be67d
commit 86cbb43965
8 changed files with 379 additions and 5 deletions

View file

@ -13,6 +13,7 @@ import (
"net/http"
"os"
"strconv"
"strings"
"github.com/tegwick/fluid-telegram/internal/adapter"
)
@ -51,8 +52,18 @@ func run() error {
AttachVisual: attachVisual,
HallBaseURL: hallBaseURL,
}
// UPLOAD_VISUALS=true: fetch images from VISUAL_HOSTS (default the forge)
// and upload them, optionally with FORGE_READ_TOKEN, so Telegram never needs
// a public image URL (FT-WP-0001-T14).
if os.Getenv("UPLOAD_VISUALS") == "true" {
hosts := strings.Split(os.Getenv("VISUAL_HOSTS"), ",")
if strings.TrimSpace(os.Getenv("VISUAL_HOSTS")) == "" {
hosts = []string{"forgejo.coulomb.social"}
}
cfg.Visuals = adapter.NewVisualFetcher(hosts, os.Getenv("FORGE_READ_TOKEN"))
}
a := adapter.New(cfg, adapter.NewBotAPISender(token), adapter.NewMemStore(), adapter.NewHTTPTelemetry(controlURL))
log.Printf("adapter listening on %s (chat_id=%d, attach_visual=%v)", addr, chatID, attachVisual)
log.Printf("adapter listening on %s (chat_id=%d, attach_visual=%v, upload_visuals=%v)", addr, chatID, attachVisual, cfg.Visuals != nil)
return http.ListenAndServe(addr, a.Handler())
}