"""Inbox helpers — attachment loading and other non-routing checks.""" from __future__ import annotations import base64 from pathlib import Path from inbox.models import Inbox_Messages def load_message_files(message: Inbox_Messages) -> list[dict]: """Read files from file_path when they exist on disk.""" if not message.file_path: return [] files: list[dict] = [] for path_str in message.file_path.split(","): path = Path(path_str.strip()) if not path.is_file(): continue try: raw = path.read_bytes() except OSError: continue files.append( { "file_name": path.name, "content_base64": base64.b64encode(raw).decode("ascii"), "size": len(raw), } ) return files