diff --git a/cmd/route_parity/main.go b/cmd/route_parity/main.go index 4dceae3a..14bb157a 100644 --- a/cmd/route_parity/main.go +++ b/cmd/route_parity/main.go @@ -244,6 +244,7 @@ var criticalRoutes = []route{ {Method: "POST", Path: "/api/v1/accounts/:account_id/integrations/linear/unlink_issue", Controller: "api/v1/accounts/integrations/linear#unlink_issue", Source: "routes.rb:371"}, {Method: "GET", Path: "/api/v1/accounts/:account_id/integrations/linear/search_issue", Controller: "api/v1/accounts/integrations/linear#search_issue", Source: "routes.rb:372"}, {Method: "GET", Path: "/api/v1/accounts/:account_id/integrations/linear/linked_issues", Controller: "api/v1/accounts/integrations/linear#linked_issues", Source: "routes.rb:373"}, + {Method: "DELETE", Path: "/api/v1/accounts/:account_id/integrations/notion", Controller: "api/v1/accounts/integrations/notion#destroy", Source: "routes.rb:379"}, {Method: "GET", Path: "/api/v1/accounts/:account_id/notifications/", Controller: "api/v1/accounts/notifications#index", Source: "routes.rb:283"}, {Method: "PUT", Path: "/api/v1/accounts/:account_id/notifications/:notification_id", Controller: "api/v1/accounts/notifications#update", Source: "routes.rb:283"}, diff --git a/docs/CHATWOOT_PARITY_DEVELOPMENT_PLAN.md b/docs/CHATWOOT_PARITY_DEVELOPMENT_PLAN.md index b49f8086..bdc29a1a 100644 --- a/docs/CHATWOOT_PARITY_DEVELOPMENT_PLAN.md +++ b/docs/CHATWOOT_PARITY_DEVELOPMENT_PLAN.md @@ -49,16 +49,16 @@ Hermes task landing checklist: ## Current Baseline -- Current tracking checkpoint: 2026-06-06 Shopify integration parity checkpoint, prepared as `feat(integrations): align shopify parity`. -- Latest implementation checkpoint: this checkpoint, prepared as `feat(integrations): align shopify parity`. +- Current tracking checkpoint: 2026-06-06 Notion integration destroy parity checkpoint, prepared as `feat(integrations): align notion parity`. +- Latest implementation checkpoint: this checkpoint, prepared as `feat(integrations): align notion parity`. - Latest documentation/tooling checkpoint: this tracker update for P3.24 plus the landed parity tracker history; this document is the active follow-up plan and supersedes `.hermes/plans/*`. - Plan landing status: complete for the current known Hermes plans and user-confirmed scope. Future work should update this file directly instead of opening a parallel tracker. -- Worktree status at this implementation checkpoint: Shopify integration account routes from `reference/chatwoot/config/routes.rb:361-364`, `Api::V1::Accounts::Integrations::ShopifyController`, `Shopify::IntegrationHelper`, Shopify callback behavior, request specs, and reused dashboard `integrations.js`/`shopify.js` API are implemented. GoChat now exposes no-trailing and trailing Shopify destroy, returns raw `{ redirect_url }` auth payloads with Chatwoot's missing-domain `422 { error }`, returns raw `{ orders: [...] }`, resolves account-scoped contacts, rejects contacts without email/phone with `422 { error: "Contact information missing" }`, queries Shopify customers by email/phone then orders by customer ID through fakeable REST clients, adds Chatwoot `admin_url`, finds hooks by `app_id: shopify`, and returns empty `200 OK` deletes. Live API/browser/enterprise smoke still needs the full PostgreSQL/Redis/Meilisearch/GoChat/Vite/Chrome stack. +- Worktree status at this implementation checkpoint: Notion account destroy from `reference/chatwoot/config/routes.rb:379`, `Api::V1::Accounts::Integrations::NotionController`, Notion callback specs, and reused dashboard integrations API are implemented. GoChat now exposes no-trailing and trailing Notion destroy routes, finds OAuth callback-created hooks by `app_id: notion` with legacy `hook_type` fallback, and returns Chatwoot-compatible empty `200 OK` deletes. Live API/browser/enterprise smoke still needs the full PostgreSQL/Redis/Meilisearch/GoChat/Vite/Chrome stack. - Next executable implementation checkpoint: continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke from fresh reference/smoke evidence. - `go test ./...` passes when run outside the restricted socket sandbox; focused Shopify handler/service tests pass in the sandbox. -- Route dump succeeds with `940` registered routes after Shopify no-trailing destroy tracking. +- Route dump succeeds with `941` registered routes after Notion no-trailing destroy tracking. - Route parity artifacts now exist under `docs/parity/` and are generated by `cmd/route_parity`. -- Tracked frontend-critical route audit covers 403 Chatwoot routes: 390 exact, 0 method-compatible, 13 parameter-compatible, 0 missing. The 13 parameter-compatible routes are Gin-internal parameter-name differences for nested AgentCapacityPolicy users/inbox limits, dashboard app member `:id` names, plus the public article `.md`/`.png` suffixes served through the same external article route dispatcher. +- Tracked frontend-critical route audit covers 404 Chatwoot routes: 391 exact, 0 method-compatible, 13 parameter-compatible, 0 missing. The 13 parameter-compatible routes are Gin-internal parameter-name differences for nested AgentCapacityPolicy users/inbox limits, dashboard app member `:id` names, plus the public article `.md`/`.png` suffixes served through the same external article route dispatcher. - `/api/v1/widget` stubs are burned down and public inbox/contact/conversation/message core flows are backed by real handlers. - Handler test stability fixes are committed into the baseline before feature parity work continues. - `.codegraph/` is generated indexing output and is not part of tracked product code. @@ -140,12 +140,13 @@ This table is the shortest authoritative handoff view. If an older lower section | Priority | Workstream | Current state | Next checkpoint | Commit close rule | | --- | --- | --- | --- | --- | +| 0 | P3.27 Notion integration destroy parity | Implemented for reused dashboard Notion integration disconnect flow: no-trailing and trailing destroy routes are registered, the account route is tracked from `routes.rb:379`, OAuth callback-created hooks are found by `app_id: notion` with legacy hook-type fallback, and delete returns empty `200 OK` instead of a local success/message envelope. | Keep in Review; reopen only if live Notion OAuth/disconnect smoke exposes feature-gate drift, callback-created hook shape drift, or frontend delete error handling beyond the inspected controller/spec/frontend contract. | Focused Notion handler/service tests, route dump/parity regeneration (`941` routes; `391 exact`, `13 parameter-compatible`, `0 missing out of 404`), full `go test ./...`, and `git diff --check` must pass before commit. | | 0 | P3.26 Shopify integration parity | Implemented for reused dashboard Shopify integration and customer-order panel: no-trailing and trailing destroy routes are registered, auth returns raw `{ redirect_url }`, missing shop domains return Chatwoot's `422 { error: "Shop domain is required" }`, orders returns raw `{ orders: [...] }`, account-scoped contacts are required, contacts without email/phone return `422 { error: "Contact information missing" }`, Shopify customers/search and orders REST calls are made through fakeable clients, order payloads include `admin_url`, callback-created hooks are found by `app_id: shopify`, and delete returns empty `200 OK`. | Keep in Review; reopen only if live Shopify OAuth/order smoke exposes token/session setup drift, REST API version drift, Shopify error-body wording, or frontend order payload drift beyond the inspected controller/helper/spec/frontend contract. | Focused Shopify handler/service tests, route dump/parity regeneration (`940` routes; `390 exact`, `13 parameter-compatible`, `0 missing out of 403`), sandbox package tests, escalated full `go test ./...`, and `git diff --check` passed. | | 0 | P3.25 Linear integration parity | Implemented for reused dashboard Linear issue flow: no-trailing and trailing destroy routes are registered, teams/team_entities/search/linked/create/link/unlink return raw Chatwoot payloads, provider errors return `422 { error }`, blank search returns Chatwoot's exact search-string error, requests proxy Linear GraphQL via fakeable clients, delete revokes Linear tokens and returns empty `200 OK`, create/link/unlink resolve conversations by account display ID, conversation links use the reused frontend URL, and successful mutations create Chatwoot-style Linear activity messages. | Keep in Review; reopen only if live Linear OAuth/GraphQL smoke exposes token refresh behavior, GraphQL query/mutation field drift, activity job queue semantics, or frontend payload drift beyond the inspected controller/processor/client/spec contract. | Focused Linear handler/service tests, route dump/parity regeneration (`939` routes; `387 exact`, `13 parameter-compatible`, `0 missing out of 400`), sandbox package tests, escalated full `go test ./...`, and `git diff --check` passed. | | 0 | P3.24 Slack integration parity | Implemented for reused dashboard Slack settings flow: no-trailing and trailing singleton routes are registered for create/update/delete, `PUT` and `PATCH` update both work, create accepts frontend `code` and exchanges it for a Slack access token, hooks are persisted with `app_id: slack` and disabled status, update accepts frontend `reference_id`, fetches real private/public Slack channels with pagination, joins public channels, persists `reference_id/settings.channel_name/status`, create/update return raw Chatwoot app payloads with hooks, list-all returns raw channel arrays, invalid channels return Chatwoot's `422 { error }`, and delete returns empty `200 OK`. | Keep in Review; reopen only if live Slack OAuth/channel smoke exposes OAuth redirect, provider error, app serializer, or Slack channel pagination drift beyond the inspected controller/builder/spec/frontend contract. | Focused Slack handler/service tests, route dump/parity regeneration, sandbox focused `go test`, escalated full `go test ./...`, and `git diff --check` passed. | | 0 | P3.23 nested contact inbox creation API | Implemented for Chatwoot nested contact inbox creation: raw JSON/form/query params are accepted, contact and inbox are account-scoped, missing source IDs are generated through Chatwoot channel rules, duplicate contact+inbox+source rows are returned idempotently, `hmac_verified` is persisted on creation, and the response is raw `{ source_id, inbox }` rather than the local model/envelope. | Keep in Review; reopen only if live CRM/new-conversation smoke exposes inbox access-policy, unsupported channel, or serializer drift beyond the inspected controller/builder/Jbuilder contract. | Focused nested ContactInbox handler/service/repository tests, route parity check, full `go test ./...`, and `git diff --check` passed. | | 1 | P3.2a invitation/confirmation mail parity | Implemented for current non-SSO reference behavior: profile resend is no longer a TODO-only log, new invited agents and unconfirmed invited profile resends generate reset-password invitation links, normal unconfirmed profile resends generate confirmation links, `users.unconfirmed_email` is modeled for email-update routing, and fakeable/environment SMTP mailers keep default tests offline. | Keep in Review; reopen only if reused frontend smoke or fresh reference evidence exposes additional Devise confirmation states outside excluded SSO/SAML/LDAP/OIDC variants. | Focused profile and agent invitation tests, combined handler/service/repository/router/migrate/app tests, full `go test ./...`, and `git diff --check` passed. | -| 2 | Phase 2/3 drift | Tracked route parity is 0 missing for the current 403-route critical set; dashboard `/app` shell routes from `routes.rb:19-20`, `.well-known` app association and custom-domain challenge routes from `routes.rb:657-660`, Twilio callback routes from `routes.rb:639-640`, enterprise Twilio voice routes from `routes.rb:643-646`, root Linear/Shopify/Notion OAuth callback routes from `routes.rb:630/634/654`, root Twitter/Google/Microsoft/Instagram/TikTok callback routes from `routes.rb:626/649-652`, assignment policy routes from `routes.rb:306-313`, help-center portal/category/article routes from `routes.rb:385-404`, public help-center portal/sitemap/article/category/search/article-detail routes from `routes.rb:590-601`, enterprise contact outbound voice call from `routes.rb:216`, account agent-bot routes from `routes.rb:94-97`, account webhook routes from `routes.rb:342`, account integration app/hook routes from `routes.rb:345-348`, account Slack routes from `routes.rb:350-352`, account Dyte routes from `routes.rb:357-358`, account Shopify routes from `routes.rb:361-364`, account Linear routes from `routes.rb:365-373`, dashboard app routes from `routes.rb:130`, canned response routes from `routes.rb:114`, notification subscription routes from `routes.rb:440`, team/team-member routes from `routes.rb:296-300`, conversation participant routes from `routes.rb:150`, conversation direct upload route from `routes.rb:151`, conversation draft message routes from `routes.rb:152`, conversation inbox assistant route from `routes.rb:165`, conversation reporting events route from `routes.rb:166`, and account reporting events route from `routes.rb:234` are now explicitly tracked. Notification list/action serializers, user notification-settings raw payloads, campaigns raw payload/display-id routes, Devise password reset/confirmation payloads, CRM shared attachment payloads plus fixed 100-row attachment pagination, account/settings payloads, assignable-agent payloads, agent index full-list behavior, agent create/update/delete defaults/errors/scope, account agent-bot route/payload/mutation behavior, account webhook payload/mutation behavior, integration app/hook payload behavior, account Slack OAuth/channel payload behavior, account Dyte create/join payload behavior, account Shopify customer-order payload behavior, account Linear GraphQL issue payload behavior, dashboard app raw payload/serializer behavior, canned response raw payload/search/delete behavior, notification subscription payload behavior, team update/frontend route behavior, conversation participant route/payload/final-set update behavior, conversation direct upload ActiveStorage behavior, conversation draft message Redis-key-equivalent behavior, conversation inbox assistant Copilot payload behavior, conversation reporting-event raw array behavior, account reporting-events payload/filter/pagination behavior, label CRUD payloads, custom filters, custom attribute definitions, contact outbound voice calls, assignment policy CRUD and inbox binding payloads, Twilio inbound/status callbacks, enterprise Twilio voice callbacks, Linear/Shopify/Notion root integration callbacks, Shopify OAuth auth redirects, root channel OAuth callbacks, help-center portal/category/article payloads, dashboard app shell route behavior, app association JSON payloads, Cloudflare custom hostname verification, public widget popular-article lists, public help-center category list/show payloads, public portal show/default-locale payloads, public portal search payloads, public article show/markdown/tracking routes, and public sitemap XML now match the inspected Chatwoot contract. | Continue the next evidence-backed route/controller/serializer drift after Shopify parity or from B12 findings. | Regenerate parity artifacts when routes change and add endpoint-family fixture tests. | +| 2 | Phase 2/3 drift | Tracked route parity is 0 missing for the current 404-route critical set; dashboard `/app` shell routes from `routes.rb:19-20`, `.well-known` app association and custom-domain challenge routes from `routes.rb:657-660`, Twilio callback routes from `routes.rb:639-640`, enterprise Twilio voice routes from `routes.rb:643-646`, root Linear/Shopify/Notion OAuth callback routes from `routes.rb:630/634/654`, root Twitter/Google/Microsoft/Instagram/TikTok callback routes from `routes.rb:626/649-652`, assignment policy routes from `routes.rb:306-313`, help-center portal/category/article routes from `routes.rb:385-404`, public help-center portal/sitemap/article/category/search/article-detail routes from `routes.rb:590-601`, enterprise contact outbound voice call from `routes.rb:216`, account agent-bot routes from `routes.rb:94-97`, account webhook routes from `routes.rb:342`, account integration app/hook routes from `routes.rb:345-348`, account Slack routes from `routes.rb:350-352`, account Dyte routes from `routes.rb:357-358`, account Shopify routes from `routes.rb:361-364`, account Linear routes from `routes.rb:365-373`, account Notion route from `routes.rb:379`, dashboard app routes from `routes.rb:130`, canned response routes from `routes.rb:114`, notification subscription routes from `routes.rb:440`, team/team-member routes from `routes.rb:296-300`, conversation participant routes from `routes.rb:150`, conversation direct upload route from `routes.rb:151`, conversation draft message routes from `routes.rb:152`, conversation inbox assistant route from `routes.rb:165`, conversation reporting events route from `routes.rb:166`, and account reporting events route from `routes.rb:234` are now explicitly tracked. Notification list/action serializers, user notification-settings raw payloads, campaigns raw payload/display-id routes, Devise password reset/confirmation payloads, CRM shared attachment payloads plus fixed 100-row attachment pagination, account/settings payloads, assignable-agent payloads, agent index full-list behavior, agent create/update/delete defaults/errors/scope, account agent-bot route/payload/mutation behavior, account webhook payload/mutation behavior, integration app/hook payload behavior, account Slack OAuth/channel payload behavior, account Dyte create/join payload behavior, account Shopify customer-order payload behavior, account Linear GraphQL issue payload behavior, account Notion destroy behavior, dashboard app raw payload/serializer behavior, canned response raw payload/search/delete behavior, notification subscription payload behavior, team update/frontend route behavior, conversation participant route/payload/final-set update behavior, conversation direct upload ActiveStorage behavior, conversation draft message Redis-key-equivalent behavior, conversation inbox assistant Copilot payload behavior, conversation reporting-event raw array behavior, account reporting-events payload/filter/pagination behavior, label CRUD payloads, custom filters, custom attribute definitions, contact outbound voice calls, assignment policy CRUD and inbox binding payloads, Twilio inbound/status callbacks, enterprise Twilio voice callbacks, Linear/Shopify/Notion root integration callbacks, Shopify OAuth auth redirects, root channel OAuth callbacks, help-center portal/category/article payloads, dashboard app shell route behavior, app association JSON payloads, Cloudflare custom hostname verification, public widget popular-article lists, public help-center category list/show payloads, public portal show/default-locale payloads, public portal search payloads, public article show/markdown/tracking routes, and public sitemap XML now match the inspected Chatwoot contract. | Continue the next evidence-backed route/controller/serializer drift after Notion parity or from B12 findings. | Regenerate parity artifacts when routes change and add endpoint-family fixture tests. | | 3 | Phase 6 placeholder audit | Widget/public/webhook critical placeholders are burned down; inbox WhatsApp health/register-webhook and sync-template drift are closed; refreshed `docs/parity/placeholder_audit.md` shows only webhook nil-handler fallbacks still call `chatwootParityStub`; dashboard conversation transcript/custom-attribute response drift and message retry status drift are closed. | Keep in Review; reopen only if fresh `rg`, route smoke, or B12 finds a frontend-reachable placeholder/stub in account/contact/conversation/message/inbox/widget/public paths. | `rg` placeholder audit and `scripts/parity_frontend_smoke.sh --check` are recorded; no reused-frontend blocker is ownerless. | | 4 | P3.9 account agent-bot API | Implemented for the reused dashboard AgentBots settings route with no-trailing-slash routes, PATCH update, raw Jbuilder-style payloads, account mutation scope, system-bot show/list visibility, empty `200 OK` delete, and full reset/avatar action payloads. | Keep in Review; reopen only if live settings smoke exposes avatar upload storage or administrator-secret gating drift. | Focused AgentBot handler tests, service/router focused tests, route dump/parity regeneration, full `go test ./...`, and `git diff --check` passed. | | 5 | P3.10 account webhooks API | Implemented for the reused dashboard Webhooks settings route with PATCH update, Chatwoot `{ payload }` list/mutation serializers, nested `{ webhook: ... }` bodies, generated secret, account-scoped mutations, URL/subscription validation, optional inbox serialization, and empty `200 OK` delete. | Keep in Review; reopen only if live settings smoke exposes audit writer or delivery-signature drift beyond the existing delivery service boundary. | Focused webhook handler/service/router tests, migration test, route dump/parity regeneration, full `go test ./...`, and `git diff --check` passed. | @@ -241,6 +242,7 @@ This ledger records the committed parity checkpoints that future slices should b | Commit | Scope | Verification summary | Follow-up state | | --- | --- | --- | --- | +| `feat(integrations): align notion parity` | Advances P3.27 Notion integration destroy parity by matching Chatwoot `Api::V1::Accounts::Integrations::NotionController#destroy`, route `379`, Notion callback hook shape, and reused dashboard integrations delete flow. GoChat now exposes no-trailing and trailing `DELETE /api/v1/accounts/:account_id/integrations/notion`, finds OAuth-created hooks by `app_id: notion` with legacy hook-type fallback, and returns empty `200 OK` instead of the local `{ message }` envelope. | `go test ./internal/service ./internal/handler/api/v1 ./cmd/route_parity -run 'NotionIntegration\|RouteParity' -count=1`; `go test ./internal/service ./internal/handler/api/v1 ./internal/router ./cmd/route_parity -run 'NotionIntegration\|Router\|RouteParity' -count=1`; `go run ./cmd/dump_routes > docs/parity/gochat_routes.txt`; `go run ./cmd/route_parity`; full `go test ./...`; `git diff --check`. Route dump is `TOTAL: 941`; tracked route parity is `391 exact, 0 method-compatible, 13 parameter-compatible, 0 missing out of 404`. | P3.27 moves to Review for current Notion destroy evidence; continue Phase 2/3 drift audit, Phase 6 placeholder audit, B12 live smoke, or fresh reference/smoke drift. | | `feat(contacts): align contact inbox creation` | Advances P3.23 nested contact inbox creation parity by matching Chatwoot `Api::V1::Accounts::Contacts::ContactInboxesController#create`, `ContactInboxBuilder`, `HmacConcern`, route `212`, request specs, and the contact inbox Jbuilder partial. GoChat now accepts raw JSON/form/query params, account-scopes contact and inbox lookup, generates source IDs for API/WebWidget/Email/Sms/Whatsapp/Twilio channels, returns existing contact+inbox+source rows idempotently, persists `hmac_verified` on creation, and returns raw `{ source_id, inbox }` instead of the local model. | `go test ./internal/handler/api/v1 ./internal/service ./internal/repository -run 'ContactInbox\|ContactHandlerCRUD' -count=1`; `go test ./internal/handler/api/v1 ./internal/service ./internal/repository ./internal/router ./cmd/route_parity -run 'ContactInbox\|ContactHandlerCRUD\|Router\|RouteParity' -count=1`; `go run ./cmd/route_parity`; full `go test ./...`; `git diff --check`. Route dump remains `TOTAL: 933`; tracked route parity remains `374 exact, 0 method-compatible, 13 parameter-compatible, 0 missing out of 387`. | P3.23 moves to Review for current nested contact inbox creation evidence; continue Phase 2/3 drift audit, Phase 6 placeholder audit, B12 live smoke, or fresh reference/smoke drift. | | `docs: land contact inbox parity plan` | Documentation-only checkpoint requested before continuing implementation. Confirms the clean committed baseline at `2072396 feat(reporting): align account events`, lands P3.23 nested contact inbox creation as the next executable slice, and records the exact Chatwoot route/controller/builder/HMAC/Jbuilder references plus Go owner files, behavior gaps, and exit gates. | `git diff --check`. No Go code or route artifacts changed. | Start `feat(contacts): align contact inbox creation`, then continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke from concrete reference/smoke evidence. | | `feat(reporting): align account events` | Advances P3.22 account reporting-events parity by matching Chatwoot enterprise `Api::V1::Accounts::ReportingEventsController#index`, route `234`, `DateRangeHelper`, request specs, and the `_reporting_event` Jbuilder partial. GoChat now returns `{ payload, meta }` instead of the local success envelope, treats date filtering as optional Unix `since/until`, supports `inbox_id`, `user_id`, and `name` filters, orders by `created_at DESC`, paginates at Chatwoot's fixed 25 rows per page, and tracks the account route in route parity. | `go test ./internal/handler/api/v1 ./internal/service ./internal/repository ./internal/router ./cmd/route_parity -run 'ReportingEvent\|Router\|RouteParity' -count=1`; `go run ./cmd/dump_routes > docs/parity/gochat_routes.txt`; `go run ./cmd/route_parity`; full `go test ./...`; `git diff --check`. Route dump is `TOTAL: 933`; tracked route parity is `374 exact, 0 method-compatible, 13 parameter-compatible, 0 missing out of 387`. | P3.22 moves to Review for current enterprise account reporting-events evidence; continue Phase 2/3 drift audit, Phase 6 placeholder audit, B12 live smoke, or fresh reference/smoke drift. | @@ -2443,3 +2445,4 @@ Verification milestone gates: - 2026-06-06: P3.24 Slack integration checkpoint prepared as `feat(integrations): align slack parity`; audited Chatwoot Slack singleton routes/controller/request specs, `Integrations::Slack::HookBuilder`, `Integrations::Slack::ChannelBuilder`, app/hook Jbuilder partials, and reused dashboard integrations API/store. GoChat now exposes no-trailing and trailing Slack singleton routes, supports `PUT` and `PATCH` update, creates disabled Slack hooks from OAuth `code`, returns raw app payloads, fetches Slack private/public channels with cursor pagination, joins public channels, persists selected channel `reference_id/settings/status`, returns raw channel arrays, maps invalid channels to Chatwoot's `422 { error }`, and deletes with empty `200 OK`. Focused handler/service tests, route dump/parity regeneration (`939` routes; `379 exact`, `13 parameter-compatible`, `0 missing out of 392`), escalated full `go test ./...`, and `git diff --check` passed; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. - 2026-06-06: P3.25 Linear integration checkpoint prepared as `feat(integrations): align linear parity`; audited Chatwoot Linear controller/request specs, processor service, GraphQL client queries/mutations, activity-message service, account routes `365-373`, and reused dashboard Linear API. GoChat now exposes no-trailing and trailing Linear destroy plus teams/team_entities/create/link/unlink/search/linked routes, calls Linear GraphQL through fakeable clients, returns raw Chatwoot data payloads, maps provider failures to `422 { error }`, resolves conversations by account display ID, builds frontend conversation links, creates Linear activity messages for create/link/unlink, revokes tokens on delete, and returns empty `200 OK`. Focused Linear handler/service tests, route dump/parity regeneration (`939` routes; `387 exact`, `13 parameter-compatible`, `0 missing out of 400`), sandbox package tests, escalated full `go test ./...`, and `git diff --check` passed; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. - 2026-06-06: P3.26 Shopify integration checkpoint prepared as `feat(integrations): align shopify parity`; audited Chatwoot Shopify account controller/specs, integration helper, callback behavior, routes `361-364`, and reused dashboard integrations/Shopify APIs. GoChat now exposes no-trailing and trailing Shopify destroy, returns raw auth/order payloads, uses Chatwoot `422 { error }` bodies for missing shop domains and missing contact info, resolves account-scoped contacts, calls Shopify customer search and orders REST endpoints through fakeable clients, appends order `admin_url`, finds callback-created hooks by `app_id: shopify`, and deletes with empty `200 OK`. Focused Shopify handler/service tests, route dump/parity regeneration (`940` routes; `390 exact`, `13 parameter-compatible`, `0 missing out of 403`), sandbox package tests, escalated full `go test ./...`, and `git diff --check` passed; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. +- 2026-06-06: P3.27 Notion integration checkpoint prepared as `feat(integrations): align notion parity`; audited Chatwoot Notion account destroy controller, route `379`, Notion callback hook shape, and reused dashboard integrations delete flow. GoChat now exposes no-trailing and trailing Notion destroy, finds callback-created hooks by `app_id: notion` with legacy hook-type fallback, tracks the account route in route parity, and deletes with empty `200 OK`. Focused Notion handler/service tests, route dump/parity regeneration (`941` routes; `391 exact`, `13 parameter-compatible`, `0 missing out of 404`), full `go test ./...`, and `git diff --check` passed; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. diff --git a/docs/parity/gochat_routes.txt b/docs/parity/gochat_routes.txt index f06bae20..a34db3e4 100644 --- a/docs/parity/gochat_routes.txt +++ b/docs/parity/gochat_routes.txt @@ -73,6 +73,7 @@ DELETE /api/v1/accounts/:account_id/inboxes/:inbox_id/web_widget/theme_config DELETE /api/v1/accounts/:account_id/integrations/hooks/:id DELETE /api/v1/accounts/:account_id/integrations/linear DELETE /api/v1/accounts/:account_id/integrations/linear/ +DELETE /api/v1/accounts/:account_id/integrations/notion DELETE /api/v1/accounts/:account_id/integrations/notion/ DELETE /api/v1/accounts/:account_id/integrations/shopify DELETE /api/v1/accounts/:account_id/integrations/shopify/ @@ -938,4 +939,4 @@ PUT /public/api/v1/csat_survey/:id PUT /public/api/v1/inboxes/:inbox_id/contacts/:contact_id PUT /public/api/v1/inboxes/:inbox_id/contacts/:contact_id/conversations/:conversation_id/messages/:message_id PUT /widget/direct_uploads/:upload_uuid -TOTAL: 940 +TOTAL: 941 diff --git a/docs/parity/route_parity.md b/docs/parity/route_parity.md index 2ca39248..3bb8709c 100644 --- a/docs/parity/route_parity.md +++ b/docs/parity/route_parity.md @@ -7,7 +7,7 @@ Generated from: This report covers tracked frontend-critical Chatwoot routes from `reference/chatwoot/config/routes.rb`, including API v1 account routes, Captain/Copilot, assignment policies, widget/public APIs, and API v2 reports. Ruby is not installed in the workspace, so Chatwoot routes are sourced from static route declarations instead of `bin/rails routes`. -Summary: 390 exact, 0 method-compatible, 13 parameter-compatible, 0 missing out of 403 tracked critical routes. +Summary: 391 exact, 0 method-compatible, 13 parameter-compatible, 0 missing out of 404 tracked critical routes. ## Missing Critical Routes @@ -78,6 +78,7 @@ These routes exist with equivalent method and path shape but different parameter | DELETE | `/api/v1/accounts/:account_id/inboxes/:inbox_id/avatar` | `/api/v1/accounts/:account_id/inboxes/:inbox_id/avatar` | `api/v1/accounts/inboxes#avatar` | `routes.rb:257` | exact | | DELETE | `/api/v1/accounts/:account_id/integrations/hooks/:id` | `/api/v1/accounts/:account_id/integrations/hooks/:id` | `api/v1/accounts/integrations/hooks#destroy` | `routes.rb:346` | exact | | DELETE | `/api/v1/accounts/:account_id/integrations/linear` | `/api/v1/accounts/:account_id/integrations/linear` | `api/v1/accounts/integrations/linear#destroy` | `routes.rb:366` | exact | +| DELETE | `/api/v1/accounts/:account_id/integrations/notion` | `/api/v1/accounts/:account_id/integrations/notion` | `api/v1/accounts/integrations/notion#destroy` | `routes.rb:379` | exact | | DELETE | `/api/v1/accounts/:account_id/integrations/shopify` | `/api/v1/accounts/:account_id/integrations/shopify` | `api/v1/accounts/integrations/shopify#destroy` | `routes.rb:361` | exact | | DELETE | `/api/v1/accounts/:account_id/integrations/slack` | `/api/v1/accounts/:account_id/integrations/slack` | `api/v1/accounts/integrations/slack#destroy` | `routes.rb:350` | exact | | DELETE | `/api/v1/accounts/:account_id/labels/:tag_id` | `/api/v1/accounts/:account_id/labels/:tag_id` | `api/v1/accounts/labels#destroy` | `routes.rb:281` | exact | diff --git a/internal/handler/api/v1/notion_integration_handler.go b/internal/handler/api/v1/notion_integration_handler.go index 34ed0b01..8f43e316 100644 --- a/internal/handler/api/v1/notion_integration_handler.go +++ b/internal/handler/api/v1/notion_integration_handler.go @@ -33,11 +33,12 @@ func (h *NotionIntegrationHandler) Delete(c *gin.Context) { handleServiceError(c, svcErr) return } - response.OK(c, gin.H{"message": "Notion integration deleted"}) + c.Status(http.StatusOK) } // RegisterNotionIntegrationRoutes registers Notion integration routes. func RegisterNotionIntegrationRoutes(g *gin.RouterGroup, h *NotionIntegrationHandler) { + g.DELETE("/notion", h.Delete) notion := g.Group("/notion") { notion.DELETE("/", h.Delete) diff --git a/internal/handler/api/v1/notion_integration_handler_test.go b/internal/handler/api/v1/notion_integration_handler_test.go index 64f65d42..e7025ed2 100644 --- a/internal/handler/api/v1/notion_integration_handler_test.go +++ b/internal/handler/api/v1/notion_integration_handler_test.go @@ -2,25 +2,43 @@ package v1 import ( "encoding/json" + "fmt" "net/http" "net/http/httptest" "testing" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gorm.io/driver/sqlite" + "gorm.io/gorm" + "gorm.io/gorm/logger" + + "github.com/gochat/gochat/internal/model" + "github.com/gochat/gochat/internal/repository" + "github.com/gochat/gochat/internal/service" ) -func setupNotionIntegrationRouter() *gin.Engine { +func setupNotionIntegrationRouter(t *testing.T) (*gin.Engine, *gorm.DB) { + t.Helper() gin.SetMode(gin.TestMode) r := gin.New() r.RedirectTrailingSlash = false - handler := NewNotionIntegrationHandler(nil) + db, err := gorm.Open(sqlite.Open("file::memory:"), &gorm.Config{Logger: logger.Default.LogMode(logger.Silent)}) + require.NoError(t, err) + require.NoError(t, db.AutoMigrate(&model.Account{}, &model.IntegrationHook{})) + t.Cleanup(func() { + sqlDB, _ := db.DB() + _ = sqlDB.Close() + }) + + handler := NewNotionIntegrationHandler(service.NewNotionIntegrationService(repository.NewIntegrationHookRepo(db))) integrations := r.Group("/api/v1/accounts/:account_id/integrations") RegisterNotionIntegrationRoutes(integrations, handler) - return r + return r, db } // ======================================== @@ -28,7 +46,7 @@ func setupNotionIntegrationRouter() *gin.Engine { // ======================================== func TestNotionIntegration_Delete_BadAccountID(t *testing.T) { - r := setupNotionIntegrationRouter() + r, _ := setupNotionIntegrationRouter(t) w := httptest.NewRecorder() req, _ := http.NewRequest("DELETE", "/api/v1/accounts/abc/integrations/notion/", nil) @@ -41,3 +59,22 @@ func TestNotionIntegration_Delete_BadAccountID(t *testing.T) { errBody := resp["error"].(map[string]interface{}) assert.Contains(t, errBody["message"], "invalid account_id") } + +func TestNotionIntegration_Delete_NoTrailingSlashReturnsEmptyOK(t *testing.T) { + r, db := setupNotionIntegrationRouter(t) + account := &model.Account{Name: "Test Account"} + require.NoError(t, db.Create(account).Error) + hook := &model.IntegrationHook{AccountID: account.ID, AppID: "notion", HookType: model.HookTypeNotion, Status: model.HookStatusActive, AccessToken: "notion-token"} + require.NoError(t, db.Create(hook).Error) + + w := httptest.NewRecorder() + req, _ := http.NewRequest("DELETE", fmt.Sprintf("/api/v1/accounts/%d/integrations/notion", account.ID), nil) + r.ServeHTTP(w, req) + + assert.Equal(t, http.StatusOK, w.Code) + assert.Empty(t, w.Body.String()) + + var count int64 + db.Model(&model.IntegrationHook{}).Where("account_id = ? AND app_id = ?", account.ID, "notion").Count(&count) + assert.Equal(t, int64(0), count) +} diff --git a/internal/service/linear_notion_integration_service.go b/internal/service/linear_notion_integration_service.go index 04ad1a92..6ba77d5a 100644 --- a/internal/service/linear_notion_integration_service.go +++ b/internal/service/linear_notion_integration_service.go @@ -601,7 +601,7 @@ func NewNotionIntegrationService(hookRepo *repository.IntegrationHookRepo) *Noti // Delete removes a Notion integration hook for an account. func (s *NotionIntegrationService) Delete(ctx context.Context, accountID uint) error { - hooks, err := s.hookRepo.FindByAccountAndType(ctx, accountID, model.HookTypeNotion) + hooks, err := s.findNotionHooks(ctx, accountID) if err != nil || len(hooks) == 0 { return fmt.Errorf("Notion integration not found for account %d", accountID) } @@ -615,3 +615,14 @@ func (s *NotionIntegrationService) Delete(ctx context.Context, accountID uint) e applogger.L().Infof("Notion integration deleted: account=%d", accountID) return nil } + +func (s *NotionIntegrationService) findNotionHooks(ctx context.Context, accountID uint) ([]model.IntegrationHook, error) { + hooks, err := s.hookRepo.FindByAccountAndApp(ctx, accountID, "notion") + if err != nil { + return nil, err + } + if len(hooks) > 0 { + return hooks, nil + } + return s.hookRepo.FindByAccountAndType(ctx, accountID, model.HookTypeNotion) +} diff --git a/internal/service/linear_notion_integration_service_test.go b/internal/service/linear_notion_integration_service_test.go index 5ddd7a63..ac064875 100644 --- a/internal/service/linear_notion_integration_service_test.go +++ b/internal/service/linear_notion_integration_service_test.go @@ -384,6 +384,26 @@ func TestNotionIntegrationService_Delete_Success(t *testing.T) { assert.Equal(t, int64(0), count) } +func TestNotionIntegrationService_Delete_FindsCallbackHookByAppID(t *testing.T) { + svc, db := setupNotionService(t) + accountID := seedLinearNotionAccount(db, t) + hook := &model.IntegrationHook{ + AccountID: accountID, + AppID: "notion", + HookType: model.HookTypeWebhook, + Status: model.HookStatusActive, + AccessToken: "callback_notion_token", + } + require.NoError(t, db.Create(hook).Error) + + err := svc.Delete(context.Background(), accountID) + assert.NoError(t, err) + + var count int64 + db.Model(&model.IntegrationHook{}).Where("account_id = ? AND app_id = ?", accountID, "notion").Count(&count) + assert.Equal(t, int64(0), count) +} + func TestNotionIntegrationService_Delete_NotFound(t *testing.T) { svc, db := setupNotionService(t) accountID := seedLinearNotionAccount(db, t)