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

Function group_poll

Scripts/ButSystem.py:15003–15055  ·  view source on GitHub ↗

Return new group messages after a given message id (AJAX polling).

(gid: int)

Source from the content-addressed store, hash-verified

15001
15002This docstring was expanded to make future maintenance easier.
15003
15004Args:
15005 call_id: Parameter.
15006
15007Returns:
15008 Varies.
15009"""
15010 if not ENABLE_CALLS:
15011 return jsonify({"ok": False, "error": "Calls disabled"}), 404
15012 me = current_user()
15013 try:
15014 since = int(request.args.get("since") or 0)
15015 except Exception:
15016 since = 0
15017 conn = db_connect()
15018 call = conn.execute("SELECT a,b,status FROM dm_calls WHERE id=?", (call_id,)).fetchone()
15019 if not call or call["status"] != "active" or (me != call["a"] and me != call["b"]):
15020 conn.close()
15021 return jsonify({"ok": False, "error": "Not allowed"}), 403
15022
15023 rows = conn.execute("""
15024 SELECT id, sender, kind, payload, created_at
15025 FROM dm_call_signals
15026 WHERE call_id=? AND id > ?
15027 ORDER BY id ASC
15028 LIMIT 120
15029 """, (call_id, since)).fetchall()
15030 conn.close()
15031 return jsonify({"ok": True, "items": [dict(r) for r in rows]})
15032
15033@app.route("/api/call/<int:call_id>/end", methods=["POST"])
15034@login_required
15035def api_call_end(call_id: int):
15036 """api_call_end.
15037
15038Route handler or application helper.
15039
15040This docstring was expanded to make future maintenance easier.
15041
15042Args:
15043 call_id: Parameter.
15044
15045Returns:
15046 Varies.
15047"""
15048 if not ENABLE_CALLS:
15049 return jsonify({"ok": False, "error": "Calls disabled"}), 404
15050 me = current_user()
15051 conn = db_connect()
15052 call = conn.execute("SELECT a,b,status FROM dm_calls WHERE id=?", (call_id,)).fetchone()
15053 if not call or call["status"] != "active" or (me != call["a"] and me != call["b"]):
15054 conn.close()
15055 return jsonify({"ok": False, "error": "Not allowed"}), 403
15056 conn.execute("UPDATE dm_calls SET status='ended', ended_at=? WHERE id=?", (now_z(), call_id))
15057 conn.execute("INSERT INTO dm_call_signals(call_id, sender, kind, payload, created_at) VALUES(?,?,?,?,?)",
15058 (call_id, me, "hangup", "{}", now_z()))

Callers

nothing calls this directly

Calls 6

current_userFunction · 0.70
group_roleFunction · 0.70
_chat_lock_is_unlockedFunction · 0.70
db_connectFunction · 0.70
aesgcm_decrypt_textFunction · 0.70
_local_time_strFunction · 0.70

Tested by

no test coverage detected