Fix !post in round-robin mode, ❓ reaction VS16, image label
- !post falls back to newest unposted story for the channel when the in-memory queue is empty (the steady state under round-robin). - Accept ❓️/❔️ (U+FE0F variation selector) as question reactions — the bare codepoints alone missed clients that render the colored emoji. - Rewrite Guardian i.guim.co.uk thumbnails to width=1200 so we stop rejecting real images as "tracking pixels"; relabel the size warning. - Log decrypt failures and reactions on events not in post_log so future silent drops surface instead of vanishing.
This commit is contained in:
@@ -3,11 +3,32 @@ package ingestion
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// NormalizeImageURL rewrites known CDN thumbnail URLs to a higher-resolution
|
||||
// variant. Currently handles Guardian's i.guim.co.uk, whose RSS feeds hand out
|
||||
// 140-px-wide thumbnails by default. Unrecognized hosts pass through unchanged.
|
||||
func NormalizeImageURL(raw string) string {
|
||||
if raw == "" {
|
||||
return raw
|
||||
}
|
||||
u, err := url.Parse(raw)
|
||||
if err != nil || u.Host != "i.guim.co.uk" {
|
||||
return raw
|
||||
}
|
||||
q := u.Query()
|
||||
if q.Get("width") == "" {
|
||||
return raw
|
||||
}
|
||||
q.Set("width", "1200")
|
||||
u.RawQuery = q.Encode()
|
||||
return u.String()
|
||||
}
|
||||
|
||||
var imageClient = &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
@@ -54,7 +75,7 @@ func ValidateImageURL(url string) bool {
|
||||
if cl := resp.Header.Get("Content-Length"); cl != "" {
|
||||
size, err := strconv.ParseInt(cl, 10, 64)
|
||||
if err == nil && size <= 5120 {
|
||||
slog.Warn("image validation: too small (likely tracking pixel)", "url", url, "size", size)
|
||||
slog.Warn("image validation: small image (≤5KB), skipping", "url", url, "size", size)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func FetchFeed(feedURL string) ([]FeedItem, error) {
|
||||
GUID: itemGUID(item),
|
||||
Headline: strings.TrimSpace(item.Title),
|
||||
Lede: extractLede(item.Description),
|
||||
ImageURL: extractImageURL(item),
|
||||
ImageURL: NormalizeImageURL(extractImageURL(item)),
|
||||
ArticleURL: strings.TrimSpace(item.Link),
|
||||
}
|
||||
if fi.GUID == "" || fi.ArticleURL == "" {
|
||||
|
||||
Reference in New Issue
Block a user