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

Function group_create

Scripts/ButSystem.py:14398–14437  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

14396 try:
14397 exists = conn.execute("SELECT 1 FROM users WHERE username=?", (username,)).fetchone()
14398 if not exists:
14399 raise ValueError("User not found")
14400
14401 cur = conn.cursor()
14402 cur.execute(
14403 "INSERT INTO dm_messages(sender, recipient, body_enc, created_at, delivered_at, read_at, has_voice, has_file) VALUES(?,?,?,?,NULL,NULL,?,?)",
14404 (
14405 me,
14406 username,
14407 aesgcm_encrypt_text(body or ""),
14408 now_z(),
14409 1 if has_voice else 0,
14410 1 if (has_file or has_gif_url) else 0,
14411 ),
14412 )
14413 dm_id = cur.lastrowid
14414
14415 # Store attachments within the SAME transaction so polling clients never see a placeholder.
14416 if has_voice:
14417 _, _, sp = _dm_store_voice_tx(conn, dm_id, voice)
14418 saved_paths.append(sp)
14419
14420 if has_file:
14421 info = _dm_store_file_tx(conn, dm_id, chosen_file)
14422 saved_paths.append(info["stored_path"])
14423
14424 if (not has_file) and has_gif_url:
14425 info = _dm_store_remote_gif_tx(conn, dm_id, gif_url)
14426 saved_paths.append(info["stored_path"])
14427
14428 conn.commit()
14429
14430 if is_ajax:
14431 r = conn.execute(
14432 "SELECT id, sender, recipient, body_enc, created_at, delivered_at, read_at, has_voice, has_file, edited_at, deleted_at FROM dm_messages WHERE id=?",
14433 (dm_id,),
14434 ).fetchone()
14435 if r is None:
14436 return jsonify(ok=False, error="Message not found"), 404
14437 msg = _dm_build_message_dict(conn, r, me)
14438 html_row = _render_dm_row_html(msg, me)
14439 return jsonify(ok=True, id=dm_id, html=html_row)
14440

Callers

nothing calls this directly

Calls 5

current_userFunction · 0.70
all_usernamesFunction · 0.70
db_connectFunction · 0.70
now_zFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected