Skip to content
This repository was archived by the owner on Nov 1, 2026. It is now read-only.

feat(webhook): restore leave approval with AM/DL authz (buttons + conversation) - #808

Merged
tieubao merged 4 commits into
mainfrom
fix/leave-notify-no-dead-buttons
Jul 22, 2026
Merged

tieubao merged 4 commits into
mainfrom
fix/leave-notify-no-dead-buttons

Conversation

@tieubao

@tieubao tieubao commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

Restores leave approval on Discord after the Neko Bot identity migration broke it, and adds the authorization the old button flow never had.

Two front-ends share one authorized backend:

  • Buttons (Approve/Reject on the notification) — handled by the Hermes gateway (ops-toolkit patch 0010), which authenticates the clicker and calls these endpoints.
  • Conversation (DM Neko Bot approve <id>) — the fortress-mcp approve_leave tool (dfoundation SPEC-087) calls the same endpoints.

Endpoints (new)

POST /webhooks/discord/leave/{list,approve,reject} — gated by API-key + PermissionCronjobExecute (unlike gen-invoice, a leave decision is a state change keyed on a claimed handle, so it must be authenticated). Only an Account Manager or Delivery Lead on the requester's active deployment (or an admin) may decide; everyone else gets 403. Reuses the existing Notion deployment/stakeholder resolution and the leave side effects (status + calendar), with an idempotency guard so a repeat approval cannot double-book the calendar. request_id accepts a page id (button) or a title (DM).

Also

  • Buttons back on the notification, custom_id notion_leave_{approve,reject}_{pageID}.
  • Handle comparison is case-folded + discriminator-stripped so a real lead is never refused.

Tests

go build ./..., go vet, go test ./pkg/handler/webhook/ green. Unit tests cover the decision logic (handle normalization, title/page-id match, idempotency). Full-chain proven by a live UAT (a real leave request posted to #project-talk tagging the AM/DL). Handler-level tests need a LeaveService interface refactor, deferred.

Follow-up (not in this PR)

Calendar-delete-on-withdraw: approve creates an event; reject/withdraw leaves it orphaned and there is no delete capability yet. Tracked in dfoundation SPEC-087.

Companion PRs: dfoundation (MCP tools + skill), ops-toolkit (gateway patches 0009/0010).

tieubao added 4 commits July 22, 2026 09:25
The Discord app that fortress-api posts with is now the Hermes desk bot, whose
slash commands are delivered over the gateway. Discord delivers interactions
either over the gateway or to an app's HTTP endpoint, never both, so that app
cannot also carry the interactions endpoint these buttons were answered on.

Rendering them anyway gives the lead a button that fails silently, which is
worse than no button. Link the Notion page instead so the request is actionable
today; approval moves into conversation with the bot next.

The custom_id handlers stay: they hold the approve/reject side effects that the
conversational path will call.
Add /webhooks/discord/leave/{list,approve,reject}, called by the fortress
MCP behind the Neko Bot desk. These add the authorization the retired
Approve/Reject buttons never had: only an Account Manager or Delivery Lead
on the requester's active deployment (or an admin) may decide a request;
everyone else gets 403. Reuses the existing Notion deployment/stakeholder
resolution and the leave side effects (status + calendar), with an
idempotency guard so a repeat approval cannot double-book the calendar.

Unlike gen-invoice (no HTTP auth, trusts its body), a leave decision is a
state change keyed on a claimed approver handle, so the routes are gated by
fortress's API-key + permission middleware. Handle comparison is
case-folded and discriminator-stripped so a real lead is never refused.

The notification now points leads at the bot command instead of a dead
button. Companion to dfoundation SPEC-087 (the MCP tools + skill) and the
ops-toolkit gateway patch 0009.
Extract the title-resolution and already-decided predicates into pure
helpers and test them alongside the handle-normalization authz check. The
full handler wiring is proven by the live UAT (a real innno_ leave request
posted to #project-talk tagging the AM/DL); a handler-level unit test would
need a LeaveService interface refactor, deferred.
Both front-ends now share one authorized backend: the buttons (handled by
the Hermes gateway, patch 0010) and the DM tool both call the leave
endpoints. Put the buttons back on the notification and make request_id
accept either a page id (button custom_id) or a title (DM). The endpoint's
AM/DL authz applies to both.
@tieubao
tieubao merged commit a1d86e6 into main Jul 22, 2026
2 of 3 checks passed
@tieubao
tieubao deleted the fix/leave-notify-no-dead-buttons branch July 22, 2026 04:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant