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

Function group_send

Scripts/ButSystem.py:14887–14996  ·  view source on GitHub ↗

Send a group message (text and/or voice) without forcing a page refresh when called via AJAX. Stability: - Commit the group message + voice attachment atomically (single transaction) so polling clients never see a blank placeholder voice row.

(gid: int)

Source from the content-addressed store, hash-verified

14885 conn.commit()
14886 conn.close()
14887 return jsonify({"ok": True})
14888
14889# ---------------------------
14890# Video call signaling (WebRTC)
14891# ---------------------------
14892
14893@app.route("/api/call/start/<peer>", methods=["POST"])
14894@login_required
14895def api_call_start(peer: str):
14896 """api_call_start.
14897
14898Route handler or application helper.
14899
14900This docstring was expanded to make future maintenance easier.
14901
14902Args:
14903 peer: Parameter.
14904
14905Returns:
14906 Varies.
14907"""
14908 if not ENABLE_CALLS:
14909 return jsonify({"ok": False, "error": "Calls disabled"}), 404
14910 me = current_user()
14911 peer = peer.strip()
14912 if peer == me:
14913 return jsonify({"ok": False, "error": "Invalid peer"}), 400
14914 conn = db_connect()
14915 exists = conn.execute("SELECT 1 FROM users WHERE username=?", (peer,)).fetchone()
14916 if not exists:
14917 conn.close()
14918 return jsonify({"ok": False, "error": "User not found"}), 404
14919
14920 # Reuse any active call between the two users
14921 row = conn.execute("""
14922 SELECT id FROM dm_calls
14923 WHERE status='active' AND ((a=? AND b=?) OR (a=? AND b=?))
14924 ORDER BY id DESC LIMIT 1
14925 """, (me, peer, peer, me)).fetchone()
14926 if row:
14927 call_id = row["id"]
14928 else:
14929 cur = conn.cursor()
14930 cur.execute("INSERT INTO dm_calls(a,b,status,created_at) VALUES(?,?, 'active', ?)", (me, peer, now_z()))
14931 call_id = cur.lastrowid
14932 conn.commit()
14933 conn.close()
14934 return jsonify({"ok": True, "call_id": call_id})
14935
14936@app.route("/api/call/peek/<peer>")
14937@login_required
14938def api_call_peek(peer: str):
14939 """If there is an active call between me and peer, return call_id (used to start polling)."""
14940 if not ENABLE_CALLS:
14941 return jsonify({"ok": False, "error": "Calls disabled"}), 404
14942 me = current_user()
14943 peer = peer.strip()
14944 conn = db_connect()

Callers

nothing calls this directly

Calls 12

current_userFunction · 0.70
group_roleFunction · 0.70
_chat_lock_is_unlockedFunction · 0.70
_locked_json_or_redirectFunction · 0.70
_filestorage_sizeFunction · 0.70
db_connectFunction · 0.70
aesgcm_encrypt_textFunction · 0.70
now_zFunction · 0.70
_group_store_voice_txFunction · 0.70
aesgcm_decrypt_textFunction · 0.70
_local_time_strFunction · 0.70

Tested by

no test coverage detected