score. Route handler or application helper. This docstring was expanded to make future maintenance easier. Args: c: Parameter. Returns: Varies.
(c)
| 13674 | else: |
| 13675 | filename = f"file_{fid}" |
| 13676 | |
| 13677 | with open(stored_path, "wb") as f: |
| 13678 | while True: |
| 13679 | chunk = resp.read(64 * 1024) |
| 13680 | if not chunk: |
| 13681 | break |
| 13682 | size += len(chunk) |
| 13683 | if size > max_bytes: |
| 13684 | raise ValueError("GIF too large") |
| 13685 | f.write(chunk) |
| 13686 | |
| 13687 | conn.execute("UPDATE dm_files SET stored_path=?, size=?, mime=?, filename=? WHERE id=?", |
| 13688 | (stored_path, int(size), mime, filename, fid)) |
| 13689 | conn.execute("UPDATE dm_messages SET has_file=1 WHERE id=?", (dm_id,)) |
| 13690 | return {"id": fid, "mime": mime, "filename": filename, "size": int(size), "stored_path": stored_path} |
| 13691 | |
| 13692 | def _dm_store_remote_gif(dm_id: int, gif_url: str) -> Dict[str, str]: |
| 13693 | """Download and store a remote GIF (or short MP4) as a DM attachment. |
| 13694 | |
| 13695 | This enables an Instagram-like GIF picker that sends a URL rather than an uploaded file. |
| 13696 | We keep this intentionally strict for safety: |
| 13697 | - only http(s) |
| 13698 | - size cap |
nothing calls this directly
no test coverage detected