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

Function group_chat

Scripts/ButSystem.py:14800–14883  ·  view source on GitHub ↗

group_chat. Chat/group feature helper or route handler. This docstring was expanded to make future maintenance easier. Args: gid: Parameter. Returns: Varies.

(gid: int)

Source from the content-addressed store, hash-verified

14798 conn.close()
14799 return jsonify(ok=True, messages=out)
14800
14801@app.route("/api/dm/message/<int:mid>/edit", methods=["POST"])
14802@login_required
14803def api_dm_edit(mid: int):
14804 """api_dm_edit.
14805
14806Chat/group feature helper or route handler.
14807
14808This docstring was expanded to make future maintenance easier.
14809
14810Args:
14811 mid: Parameter.
14812
14813Returns:
14814 Varies.
14815"""
14816 me = current_user()
14817 data = request.get_json(silent=True) or {}
14818 body = (data.get("body") or "").strip()
14819 if not body:
14820 return jsonify({"ok": False, "error": "Empty message"}), 400
14821
14822 conn = db_connect()
14823 r = conn.execute("SELECT sender, recipient, has_voice, has_file, deleted_at FROM dm_messages WHERE id=?", (mid,)).fetchone()
14824 if not r or r["sender"] != me:
14825 conn.close()
14826 return jsonify({"ok": False, "error": "Not allowed"}), 403
14827 if r["deleted_at"]:
14828 conn.close()
14829 return jsonify({"ok": False, "error": "Message deleted"}), 400
14830 if r["has_voice"] or r["has_file"]:
14831 conn.close()
14832 return jsonify({"ok": False, "error": "Only text messages can be edited"}), 400
14833
14834 conn.execute("UPDATE dm_messages SET body_enc=?, edited_at=? WHERE id=?", (aesgcm_encrypt_text(body), now_z(), mid))
14835 conn.commit()
14836 conn.close()
14837 return jsonify({"ok": True})
14838
14839@app.route("/api/dm/message/<int:mid>/delete", methods=["POST"])
14840@login_required
14841def api_dm_delete(mid: int):
14842 """api_dm_delete.
14843
14844Chat/group feature helper or route handler.
14845
14846This docstring was expanded to make future maintenance easier.
14847
14848Args:
14849 mid: Parameter.
14850
14851Returns:
14852 Varies.
14853"""
14854 me = current_user()
14855 conn = db_connect()
14856 r = conn.execute("SELECT sender, recipient, has_voice, has_file FROM dm_messages WHERE id=?", (mid,)).fetchone()
14857 if not r or r["sender"] != me:

Callers

nothing calls this directly

Calls 11

current_userFunction · 0.70
group_roleFunction · 0.70
db_connectFunction · 0.70
is_onlineFunction · 0.70
current_scopeFunction · 0.70
_chat_lock_existsFunction · 0.70
_chat_lock_is_unlockedFunction · 0.70
ObjClass · 0.70
all_usernamesFunction · 0.70
aesgcm_decrypt_textFunction · 0.70
_local_time_strFunction · 0.70

Tested by

no test coverage detected