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

Function api_call_poll

Scripts/ButSystem.py:14127–14161  ·  view source on GitHub ↗

api_call_poll. Route handler or application helper. This docstring was expanded to make future maintenance easier. Args: call_id: Parameter. Returns: Varies.

(call_id: int)

Source from the content-addressed store, hash-verified

14125 pass
14126 try:
14127 db_init()
14128 except Exception:
14129 pass
14130 conn = db_connect()
14131 try:
14132 conn.execute("""
14133 UPDATE dm_messages SET delivered_at=?
14134 WHERE sender=? AND recipient=? AND delivered_at IS NULL
14135 """, (now_z(), username, me))
14136 conn.execute("""
14137 UPDATE dm_messages SET read_at=?
14138 WHERE sender=? AND recipient=? AND read_at IS NULL
14139 """, (now_z(), username, me))
14140 conn.commit()
14141
14142 rows = conn.execute("""
14143 SELECT id, sender, recipient, body_enc, created_at, delivered_at, read_at, has_voice, has_file, edited_at, deleted_at
14144 FROM dm_messages
14145 WHERE (sender=? AND recipient=?) OR (sender=? AND recipient=?)
14146 ORDER BY id ASC
14147 LIMIT 400
14148 """, (me, username, username, me)).fetchall()
14149 except Exception:
14150 try:
14151 conn.close()
14152 except Exception:
14153 pass
14154 flash("Internal error opening chat. Please try again.")
14155 return redirect(url_for("chats"))
14156
14157 msgs = []
14158 last_id = 0
14159 for r in rows:
14160 last_id = max(last_id, int(r["id"]))
14161 if r["has_voice"]:
14162 v = conn.execute("SELECT id, mime FROM dm_voice WHERE dm_id=? ORDER BY id DESC LIMIT 1", (r["id"],)).fetchone()
14163 else:
14164 v = None

Callers

nothing calls this directly

Calls 2

current_userFunction · 0.70
db_connectFunction · 0.70

Tested by

no test coverage detected