max-telegram-bridge-bot/addon_errs_test.go
Andrey Lugovskoy f57105d2b6
Some checks failed
Build / build (push) Has been cancelled
crosspost: fix long album caption + strip custom emoji and whitespace padding
- MAX→TG album: caption over Telegram's 1024 media-group limit is no longer lost —
  the album is sent without an inline caption and the full text follows as a
  separate message (sendMaxAlbumToTg, covers both direct and queued delivery).
- Forwarded text: strip Telegram custom_emoji (MAX can't render them; the fallback
  glyph only littered the copy) in tgEntitiesToHTML, and collapse whitespace padding
  (runs of spaces/nbsp, trailing spaces, 3+ blank lines) in crosspost captions —
  cuts bloated length (MAX ~4000 char limit) and fixes ugly gaps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ajcn7YhgeexPwbfrUNMj8u
2026-07-03 13:00:46 +04:00

35 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//go:build addon
package main
import "testing"
func TestIsUnforwardable_RecipientRestrictions(t *testing.T) {
// Пост СУЩЕСТВУЕТ, но не форвардится в скретч-ЛС (приватность получателя) —
// должен трактоваться как unforwardable (exists=true), а не как фатал/«поста нет».
unforwardable := []string{
"telegram: bad request, Bad Request: VOICE_MESSAGES_FORBIDDEN (400)",
"Bad Request: VIDEO_MESSAGES_FORBIDDEN (400)",
"Bad Request: CHAT_FORWARDS_RESTRICTED",
"message can't be copied",
"This message can't be forwarded",
}
for _, s := range unforwardable {
if !isUnforwardable(s) {
t.Errorf("isUnforwardable(%q) = false, want true", s)
}
if isAddonMsgGone(s) {
t.Errorf("isAddonMsgGone(%q) = true, want false (пост есть)", s)
}
}
// Реально отсутствующий пост — НЕ unforwardable, это «поста нет».
gone := []string{"Bad Request: message to forward not found", "MESSAGE_ID_INVALID"}
for _, s := range gone {
if isUnforwardable(s) {
t.Errorf("isUnforwardable(%q) = true, want false", s)
}
if !isAddonMsgGone(s) {
t.Errorf("isAddonMsgGone(%q) = false, want true", s)
}
}
}