fix: detect correct message type from file mime instead of blanket DOCUMENT

Images need PHOTO for vision, audio needs VOICE for STT,
and other files get DOCUMENT for text inlining.
This commit is contained in:
Neri Cervin
2026-04-06 17:03:50 -03:00
committed by Teknium
parent 3282b7066c
commit f3ae2491a3

View File

@@ -661,8 +661,6 @@ class MattermostAdapter(BasePlatformAdapter):
msg_type = MessageType.TEXT
if message_text.startswith("/"):
msg_type = MessageType.COMMAND
elif file_ids:
msg_type = MessageType.DOCUMENT
# Download file attachments immediately (URLs require auth headers
# that downstream tools won't have).
@@ -703,6 +701,15 @@ class MattermostAdapter(BasePlatformAdapter):
except Exception as exc:
logger.warning("Mattermost: error downloading file %s: %s", fid, exc)
# Set message type based on downloaded media types.
if media_types and msg_type == MessageType.TEXT:
if any(m.startswith("image/") for m in media_types):
msg_type = MessageType.PHOTO
elif any(m.startswith("audio/") for m in media_types):
msg_type = MessageType.VOICE
elif media_types:
msg_type = MessageType.DOCUMENT
source = self.build_source(
chat_id=channel_id,
chat_type=chat_type,