← Commit history

Publish 1.6.6

Drew Owens ·33c4fbdcb5 ·3mo ago ·parent 6a58d78
4 files changed +62−5
bin/__pycache__/wiki-notify-gchatcpython-312.pyc
⋯ 1 unchanged line ⋯
bin/wiki-notify-gchat+60−3
@@ -256,6 +256,60 @@ def enrich_issue_meta(state, me_full):             it["metaFetched"] = True  +def sync_issue_status(state, cfg, force=False):+    """Reconcile board items against the wiki DB (throttled, default 10 min).+    Your own actions (e.g. closing an issue yourself) send you no email, so+    the email stream alone leaves the board stale - the DB is the authority."""+    now = time.time()+    if not force and now - state.get("lastStatusSync", 0) < 600:+        return False+    state["lastStatusSync"] = now+    items = state.get("items", {})+    by_page = {}+    for it in items.values():+        if it.get("num"):+            by_page.setdefault(it["page"], []).append(it)+    changed = False+    for page, its in by_page.items():+        code, out, _ = run_cmd(["adom-wiki", "issue", "list", page, "--json"])+        if code != 0:+            continue+        try:+            j = json.loads(out)+            discs = {str(dd.get("number")): dd+                     for dd in (j.get("data", j) or {}).get("discussions", [])}+        except Exception:+            continue+        for it in its:+            dd = discs.get(str(it["num"]))+            if not dd or dd.get("status") not in ("open", "closed"):+                continue+            if dd["status"] == it["status"]:+                continue+            it["status"] = dd["status"]+            changed = True+            if dd["status"] == "closed":+                ts = it["lastAt"]+                try:+                    dt = datetime.strptime(dd.get("closed_at", ""), "%Y-%m-%d %H:%M:%S").replace(tzinfo=timezone.utc)+                    ts = int(dt.timestamp() * 1000)+                except (ValueError, TypeError):+                    pass+                it["closedAt"] = ts+                if ts >= it["lastAt"]:+                    it["lastAt"] = ts+                    it["lastEvent"] = "closed"+                    if dd.get("closed_by_name"):+                        it["actor"] = dd["closed_by_name"]+                log_line(f"OK status sync: {it['page']}#{it['num']} -> closed (wiki DB)")+            else:+                it["closedAt"] = None+                log_line(f"OK status sync: {it['page']}#{it['num']} -> reopened (wiki DB)")+    if changed:+        save_state(state)+    return changed++ def annotate_page_ownership(state, me_full):     """Mark items with page authorship (drives 'owns this page') + hero URL."""     state.pop("pageAuthors", None)  # superseded cache key@@ -494,10 +548,11 @@ def render_table_widgets(shown, tz, me="You"):         ]         # involvement renders ONLY when it adds a fact the labeled lines above         # don't already state: "opened this" duplicates Issue-opened-by,-        # "owns this page" duplicates Page-author, and "was mentioned"-        # duplicates a Latest line that says "mentioned you".+        # "owns this page" duplicates Page-author, "was mentioned" duplicates+        # a Latest line saying "mentioned you", and "watches this page" is+        # implied by receiving the notification at all.         inv = it.get("invLabel", "")-        if inv == "opened this":+        if inv in ("opened this", "watches this page"):             inv = ""         if inv == "was mentioned" and ev == "mention":             inv = ""@@ -747,6 +802,7 @@ def cmd_run(as_json, dry_run=False, quiet=False):         try:             me_full = cfg.get("fullName") or state.get("meFullName", "")             enrich_issue_meta(state, me_full)+            sync_issue_status(state, cfg)             annotate_page_ownership(state, me_full)             board_changed = push_board(cfg, state)         except Exception as e:@@ -811,6 +867,7 @@ def cmd_board(as_json, dry_run=False):         return     me_full = cfg.get("fullName") or state.get("meFullName", "")     enrich_issue_meta(state, me_full)+    sync_issue_status(state, cfg, force=True)     annotate_page_ownership(state, me_full)     changed = push_board(cfg, state, force=True)     emit(f"OK: board {'reposted' if changed else 'unchanged'} ({len(state['items'])} item(s)).")
package.json+1−1
@@ -2,7 +2,7 @@   "slug": "wiki-notify-gchat",   "title": "Wiki Notify for Google Chat",   "type": "app",-  "version": "1.6.5",+  "version": "1.6.6",   "description": "Turn wiki.adom.inc notification emails into a live Google Chat board. One card, one row per issue - newest first, OPEN/CLOSED status, origination date, actor, and a View link - continuously updated in your own Chat space via your own webhook. Emails are swept out of your inbox (trash, archive, or label). Closed items linger until 6am the next day, then drop off. Delegates all auth to adom-google; the only secret is your webhook URL, kept in your private config.",   "tags": [     "cli",
page.json+1−1
@@ -2,7 +2,7 @@   "slug": "wiki-notify-gchat",   "title": "Wiki Notify for Google Chat",   "type": "app",-  "version": "1.6.5",+  "version": "1.6.6",   "description": "Turn wiki.adom.inc notification emails into a live Google Chat board. One card, one row per issue - newest first, OPEN/CLOSED status, origination date, actor, and a View link - continuously updated in your own Chat space via your own webhook. Emails are swept out of your inbox (trash, archive, or label). Closed items linger until 6am the next day, then drop off. Delegates all auth to adom-google; the only secret is your webhook URL, kept in your private config.",   "tags": [     "cli",