fix(gateway): stop Matrix upload fallback from leaking host path

The Matrix adapter's _upload_file fell back to sending
"(file not found: {file_path})" directly into the room — the same
host-path leak class fixed for the base adapter and Slack in the
previous commit. Replace it with a friendly notice, log the path at
WARN for operators, and preserve any caller-supplied caption.
This commit is contained in:
teknium1 2026-06-30 03:10:02 -07:00 committed by Teknium
parent cb9d18c759
commit f5eb4c307b

View file

@ -2149,9 +2149,14 @@ class MatrixAdapter(BasePlatformAdapter):
"""Read a local file and upload it."""
p = Path(file_path).expanduser()
if not p.exists():
return await self.send(
room_id, f"{caption or ''}\n(file not found: {file_path})", reply_to
# file_path is a host-local path; never echo it into chat.
logger.warning(
"[%s] upload fallback: media file not found for %s",
self.name, file_path,
)
text = f"{caption}\n⚠️ Couldn't deliver the attachment." if caption \
else "⚠️ Couldn't deliver the attachment."
return await self.send(room_id, text, reply_to)
try:
file_size = p.stat().st_size
except OSError: