api_dm_edit. Chat/group feature helper or route handler. This docstring was expanded to make future maintenance easier. Args: mid: Parameter. Returns: Varies.
(mid: int)
| 13931 | |
| 13932 | |
| 13933 | @app.route("/discussion/file/<int:fid>/download") |
| 13934 | @login_required |
| 13935 | def discussion_file_download(fid: int): |
| 13936 | """Download a Discussion attachment with a filename.""" |
| 13937 | _feature_tables_init() |
| 13938 | conn = db_connect() |
| 13939 | row = conn.execute(""" |
| 13940 | SELECT id, filename, mime, stored_path |
| 13941 | FROM discussion_files |
| 13942 | WHERE id=? |
| 13943 | """, (fid,)).fetchone() |
| 13944 | conn.close() |
| 13945 | if not row: |
| 13946 | abort(404) |
| 13947 | |
| 13948 | sp = row["stored_path"] |
| 13949 | if not sp or not os.path.exists(sp): |
| 13950 | abort(404) |
| 13951 | |
| 13952 | filename = row["filename"] or f"file_{fid}" |
| 13953 | mime = row["mime"] or "application/octet-stream" |
| 13954 | |
| 13955 | try: |
| 13956 | if is_encrypted_file(sp): |
| 13957 | gen = aesgcm_decrypt_generator(sp) |
| 13958 | headers = {"Content-Disposition": f'attachment; filename="{filename}"'} |
| 13959 | return Response(gen, mimetype=mime, headers=headers) |
| 13960 | except Exception: |
| 13961 | abort(404) |
| 13962 | |
| 13963 | from flask import send_file |
| 13964 | return send_file(sp, mimetype=mime, as_attachment=True, download_name=filename) |
| 13965 | |
| 13966 | |
| 13967 | @app.route("/discussion/voice/<int:vid>") |
| 13968 | @login_required |
| 13969 | def discussion_voice_stream(vid: int): |
| 13970 | """Stream a Discussion voice message.""" |
nothing calls this directly
no test coverage detected