Fire automation events across API routers
FlowDeck CI / lint (push) Failing after 1m12s
FlowDeck CI / test (push) Failing after 3h3m3s
FlowDeck CI / docker (push) Skipped

This commit is contained in:
2026-09-21 20:30:05 -04:00
parent 189ed5bbca
commit e0237e576f
8 changed files with 202 additions and 2 deletions
+22
View File
@@ -130,6 +130,10 @@ async def add_comment(request: Request, page_id: int):
cur = conn.execute("INSERT INTO comments (page_id, user_id, body, parent_id) VALUES (?,?,?,?)",
(page_id, uid, b, parent_id))
conn.commit()
try:
await fire_event("comment.added", {"comment_id": cur.lastrowid, "page_id": page_id, "user_id": uid})
except Exception:
pass
return {"id": cur.lastrowid, "status": "created"}
@@ -139,11 +143,17 @@ async def update_comment(request: Request, comment_id: int):
b = body.get("body")
resolved = body.get("resolved")
with get_conn() as conn:
row = conn.execute("SELECT page_id, resolved FROM comments WHERE id=?", (comment_id,)).fetchone()
if b is not None:
conn.execute("UPDATE comments SET body=?, updated_at=CURRENT_TIMESTAMP WHERE id=?", (b, comment_id))
if resolved is not None:
conn.execute("UPDATE comments SET resolved=? WHERE id=?", (int(resolved), comment_id))
conn.commit()
if resolved and row and not int(row["resolved"] or 0):
try:
await fire_event("comment.resolved", {"comment_id": comment_id, "page_id": row["page_id"]})
except Exception:
pass
return {"status": "updated"}
@@ -206,6 +216,10 @@ async def add_favorite(request: Request):
(uid, page_id, collection_id),
)
conn.commit()
try:
await fire_event("favorite.added", {"page_id": page_id, "collection_id": collection_id, "user_id": uid})
except Exception:
pass
return {"status": "favorited"}
@@ -449,6 +463,10 @@ async def create_sprint(request: Request, collection_id: int):
(collection_id, name, start_date, end_date, goal, status, auto_complete),
)
conn.commit()
try:
await fire_event("sprint.created", {"sprint_id": cur.lastrowid, "collection_id": collection_id, "name": name})
except Exception:
pass
return {"id": cur.lastrowid, "name": name, "status": "created"}
@@ -475,6 +493,10 @@ async def update_sprint(request: Request, collection_id: int, sid: int):
(name, start_date, end_date, goal, status, auto_complete, sid),
)
conn.commit()
try:
await fire_event("sprint.updated", {"sprint_id": sid, "collection_id": collection_id, "name": name, "status": status})
except Exception:
pass
return {"id": sid, "status": "updated"}