MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / api_dm_edit

Function api_dm_edit

Scripts/ButSystem.py:13933–13967  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13931 conditional=True,
13932 max_age=0,
13933 )
13934 except Exception:
13935 abort(404)
13936
13937 disp_type = "inline" if inline_ok else "attachment"
13938 resp.headers["Content-Disposition"] = f'{disp_type}; filename="{filename}"'
13939 resp.headers["Cache-Control"] = "no-store"
13940 return resp
13941
13942
13943@app.route("/discussion/file/<int:fid>/download")
13944@login_required
13945def discussion_file_download(fid: int):
13946 """Download a Discussion attachment with a filename."""
13947 _feature_tables_init()
13948 conn = db_connect()
13949 row = conn.execute("""
13950 SELECT id, filename, mime, stored_path
13951 FROM discussion_files
13952 WHERE id=?
13953 """, (fid,)).fetchone()
13954 conn.close()
13955 if not row:
13956 abort(404)
13957
13958 sp = row["stored_path"]
13959 if not sp or not os.path.exists(sp):
13960 abort(404)
13961
13962 filename = row["filename"] or f"file_{fid}"
13963 mime = row["mime"] or "application/octet-stream"
13964
13965 try:
13966 if is_encrypted_file(sp):
13967 gen = aesgcm_decrypt_generator(sp)
13968 headers = {"Content-Disposition": f'attachment; filename="{filename}"'}
13969 return Response(gen, mimetype=mime, headers=headers)
13970 except Exception:

Callers

nothing calls this directly

Calls 4

current_userFunction · 0.70
db_connectFunction · 0.70
aesgcm_encrypt_textFunction · 0.70
now_zFunction · 0.70

Tested by

no test coverage detected