fix: complete send_message MEDIA delivery salvage
- prevent raw MEDIA tag leakage outside the gateway pipeline - make extract_media handle quoted/backticked paths and optional whitespace - send Telegram media natively with explicit error/warning handling - add regression tests for Telegram media dispatch and MEDIA parsing
This commit is contained in:
parent
50d6659392
commit
5c9a84219d
4 changed files with 309 additions and 44 deletions
|
|
@ -258,6 +258,29 @@ class TestExtractMedia:
|
|||
_, cleaned = BasePlatformAdapter.extract_media(content)
|
||||
assert "\n\n\n" not in cleaned
|
||||
|
||||
def test_media_tag_allows_optional_whitespace_after_colon(self):
|
||||
content = "MEDIA: /path/to/audio.ogg"
|
||||
media, cleaned = BasePlatformAdapter.extract_media(content)
|
||||
assert media == [("/path/to/audio.ogg", False)]
|
||||
assert cleaned == ""
|
||||
|
||||
def test_media_tag_strips_wrapping_quotes_and_backticks(self):
|
||||
content = "MEDIA: `/path/to/file.png`\nMEDIA:\"/path/to/file2.png\"\nMEDIA:'/path/to/file3.png'"
|
||||
media, cleaned = BasePlatformAdapter.extract_media(content)
|
||||
assert media == [
|
||||
("/path/to/file.png", False),
|
||||
("/path/to/file2.png", False),
|
||||
("/path/to/file3.png", False),
|
||||
]
|
||||
assert cleaned == ""
|
||||
|
||||
def test_media_tag_supports_quoted_paths_with_spaces(self):
|
||||
content = "Here\nMEDIA: '/tmp/my image.png'\nAfter"
|
||||
media, cleaned = BasePlatformAdapter.extract_media(content)
|
||||
assert media == [("/tmp/my image.png", False)]
|
||||
assert "Here" in cleaned
|
||||
assert "After" in cleaned
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# truncate_message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue