Skip to content

fix: resolve fork-caused defects from code review audit - #4

Open
JOY (JOY) wants to merge 31 commits into
mainfrom
fix/audit-fork-defects
Open

fix: resolve fork-caused defects from code review audit#4
JOY (JOY) wants to merge 31 commits into
mainfrom
fix/audit-fork-defects

Conversation

@JOY

@JOY JOY (JOY) commented Sep 8, 2026

Copy link
Copy Markdown

What

Fixes for the fork-caused defects surfaced by the code review audit (docs/CROVE_DESK_AUDIT.html). Also carries the submodule cleanup (9a25b41f) and the audit document itself.

Fixes

ID Fix
SEC-11 Meta webhook GET verification (threads, messenger, whatsapp, instagram): require a configured channel and a constant-time verify-token match before echoing hub.challenge — an unbound echo let anyone confirm a webhook subscription they do not own
BUG-05 X and TikTok outboxes added to the 5s cron drain (previously relied solely on the fire-and-forget goroutine at enqueue)
BUG-06 viber client rejects non-2xx responses instead of unmarshaling error bodies
BUG-10 email SMTP uses net.JoinHostPort — IPv6 literal hosts now dial correctly, go vet clean
BUG-20 en-US/zh-CN: add missing common.{actions,name,delete,edit,create,refresh,description} + knowledge.status
BUG-22 replace the undefined --font-inter var with the loaded --font-geist-sans — the whole font-family declarations were being discarded at computed-value time
BUG-25 drop the stale applyBranding call in the locale provider (the [locale, publicConfig] effect applies branding with fresh state)

Retracted audit claims

  • BUG-02 — already fixed in 6a3b9c7c (externalID = username)
  • BUG-03 — not reproducible; enqueue guards are identical across channels on direct read
  • BUG-07 — token input exists; disabled by design (backend auto-generates the token)
  • BUG-25 — narrowed: the [locale, publicConfig] effect self-heals the title

Verification

  • go build ./internal/... · go vet (touched packages) ✓
  • go test ./internal/handlers/third/... ✓ · go test ./internal/services/...
  • pnpm typecheck ✓ · gofmt ✓ · git diff --check

Not included (owner actions)

  • SEC-06 — rotate the leaked DOS.AI key at the provider + purge git history (git filter-repo)
  • ARCH-02 — KB seed multi-tenancy wording (content decision)

Note

Medium Risk
Webhook verification and outbox cron changes reduce real exploit/reliability risk, but the PR also expands many inbound channel routes and Docker/DB defaults while numerous P0 audit items (auth, uploads, guest impersonation) remain unfixed.

Overview
This PR bundles audit-driven fork fixes with Crove Desk packaging/docs and a large omnichannel surface area (routes, OAuth URL endpoints, Discord client, customer API enrichments).

Security & reliability fixes tighten Meta-family webhook GET verification (configured channel + constant-time verify token before echoing hub.challenge), add X/TikTok to the 5s outbox cron drain, make the Viber client fail on non-2xx responses, fix SMTP dialing via net.JoinHostPort, remove the hardcoded DOS.AI key from the live agent test (skip when unset), and soften default KB copy so multi-tenancy is not overstated.

Frontend/i18n adds missing common.* / knowledge.status keys in en-US/zh-CN and replaces undefined --font-inter with --font-geist-sans; the i18n provider drops a stale applyBranding call on locale change.

Platform & ops shift defaults toward Supabase Postgres (.env.example, docker-compose without MySQL, crove-desk image, .env + host.docker.internal), drop git submodules for docs/qdrant, and expand .dockerignore for monorepo builds.

Product/engine registers many third-party channel webhooks and dashboard OAuth URL routes, introduces a Discord REST client, adds customer merge plus identity/channel fields on customer and conversation responses, and adds extensive in-repo architecture, audit register, backlog, and channel integration specs (plus Cursor interaction rules).

Reviewed by Cursor Bugbot for commit 95b32c6. Configure here.

…ation

- add discord and messenger channel and identity enums with generated frontend types

- implement internal discord and messenger REST API clients

- add discord and messenger inbound webhook services with customer identity resolution and rich media attachment support

- add async outbox delivery services for discord and messenger with retry handling

- register third webhook endpoints and 1-click oauth authorization handlers

- update dashboard channels list and edit dialog with discord and messenger configurations

- add full multilingual translation keys across en-US, vi-VN, and zh-CN
- REST API clients (internal/line, internal/viber, internal/threads) with webhook
  signature verification (HMAC-SHA256 base64 for LINE, hex for Viber, sha256 for Meta)
- Inbound services mapping external identity, conversation dedupe, and customer
  message persistence per channel
- Async outbox delivery via ChannelMessageOutbox with batch 20 / max retry 5 /
  linear backoff, wired into cron and message service hooks
- Third-party webhook endpoints under /api/third/{line,viber,threads} with
  Meta-style hub.challenge verification for Threads
- Viber conversation_started welcome message response support
- Threads replies anchor to the latest customer media id for two-step publish
- Dashboard channel create/edit forms, icons, and i18n for en-US, zh-CN, vi-VN
- Degrade image/attachment messages to signed URL text on outbound (matches
  TikTok pattern); outbox enqueue now accepts image/attachment so agent media
  no longer silently drops for the new channels
- Threads webhook signature check is fail-closed once AppSecret is configured
- Use the stable @username as the Threads customer identity to prevent
  conversation fragmentation per reply (media id stays the dedupe key)
- Fall back to the channel name as the Viber sender name when botName is unset
- LINE: send the configured welcome message on follow events
- Round-trip all channel config fields through the edit dialog (welcome
  message, avatar URL, webhook secret) so saving no longer drops values set
  outside the form
- Show the auto-generated Threads webhook verify token read-only in the form
- Distinct icon for Threads channels
docs/ pointed to huabeitech/agent-desk-docs (private, never initialized locally), so the Crove-internal documents in it were unversioned. Remove the gitlink and track them as regular files.

qdrant/ was an empty, unused gitlink (compose uses the qdrant/qdrant Docker Hub image; code uses github.com/qdrant/go-client). With both entries gone, .gitmodules is deleted as well.
- Meta webhook GET verification (threads, messenger, whatsapp, instagram): require a configured channel and a constant-time verify-token match before echoing hub.challenge - an unbound echo let anyone confirm a webhook subscription they do not own

- cron: drain X and TikTok outboxes, which relied solely on the fire-and-forget goroutine at enqueue

- viber client: reject non-2xx responses instead of unmarshaling error bodies

- email SMTP: use net.JoinHostPort so IPv6 literal hosts dial correctly (go vet)

- frontend: replace the undefined --font-inter var with the loaded --font-geist-sans so font-family declarations stop being discarded; add the common and knowledge.status keys missing from en-US and zh-CN; drop the stale applyBranding call in the locale provider
Mark the 7 IDs fixed in the fix commit (SEC-11 plus three identical Meta-handler siblings, BUG-05, BUG-06, BUG-10, BUG-20, BUG-22, BUG-25) and retract BUG-02 (already fixed in 6a3b9c7), BUG-03 (guards are identical on read), BUG-07 (token input exists, disabled by design) and BUG-25 (narrowed: the locale/publicConfig effect self-heals the title).
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 140 files, which is 40 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Check out review usage here.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0fcdbedc-fad0-49e4-b280-9f05a33cb1f8

📥 Commits

Reviewing files that changed from the base of the PR and between db1fe7b and 95b32c6.

⛔ Files ignored due to path filters (1)
  • web/lib/generated/enums.ts is excluded by !**/generated/**
📒 Files selected for processing (140)
  • .cursor/rules/user-interaction-preferences.mdc
  • .dockerignore
  • .env.example
  • .gitmodules
  • docker-compose.yml
  • docs
  • docs/ARCHITECTURE.md
  • docs/CROVE_DESK_AUDIT.html
  • docs/CROVE_DESK_PRODUCT_BACKLOG.md
  • docs/OMNICHANNEL_CONVERSATIONAL_SUPPORT_REFACTOR.md
  • docs/superpowers/plans/2026-09-02-discord-messenger-integration.md
  • docs/superpowers/specs/2026-09-02-discord-messenger-integration-design.md
  • internal/ai/agent_loop_live_test.go
  • internal/bootstrap/default_kb.go
  • internal/bootstrap/routes.go
  • internal/bootstrap/server.go
  • internal/builders/conversation_builder.go
  • internal/builders/customer_builder.go
  • internal/discord/client.go
  • internal/discord/client_test.go
  • internal/discord/types.go
  • internal/email/client.go
  • internal/handlers/dashboard/channel_oauth_handler.go
  • internal/handlers/dashboard/customer_handler.go
  • internal/handlers/third/discord_handler.go
  • internal/handlers/third/discord_handler_test.go
  • internal/handlers/third/instagram_handler.go
  • internal/handlers/third/instagram_handler_test.go
  • internal/handlers/third/line_handler.go
  • internal/handlers/third/messenger_handler.go
  • internal/handlers/third/messenger_handler_test.go
  • internal/handlers/third/slack_handler.go
  • internal/handlers/third/threads_handler.go
  • internal/handlers/third/tiktok_handler.go
  • internal/handlers/third/viber_handler.go
  • internal/handlers/third/whatsapp_handler.go
  • internal/handlers/third/whatsapp_slack_handler_test.go
  • internal/handlers/third/x_handler.go
  • internal/handlers/third/x_tiktok_handler_test.go
  • internal/line/client.go
  • internal/line/client_test.go
  • internal/line/types.go
  • internal/messenger/client.go
  • internal/messenger/client_test.go
  • internal/messenger/types.go
  • internal/migration/000011_auto_provision_agent_profiles.go
  • internal/models/models.go
  • internal/oidcclient/oidcclient.go
  • internal/pkg/config/config.go
  • internal/pkg/config/config_test.go
  • internal/pkg/dto/dto.go
  • internal/pkg/dto/request/customer_request.go
  • internal/pkg/dto/request/webhook_request.go
  • internal/pkg/dto/response/conversation_response.go
  • internal/pkg/dto/response/customer_response.go
  • internal/pkg/enums/channel_enums_test.go
  • internal/pkg/enums/external_identity.go
  • internal/pkg/enums/wxwork_kf.go
  • internal/repositories/customer_contact_repository.go
  • internal/services/agent_profile_service.go
  • internal/services/auth_service_test.go
  • internal/services/channel_message_outbox_service.go
  • internal/services/channel_service.go
  • internal/services/conversation_service.go
  • internal/services/cronx/cron.go
  • internal/services/customer_merge_test.go
  • internal/services/customer_service.go
  • internal/services/customer_service_test.go
  • internal/services/discord_inbound_service.go
  • internal/services/discord_inbound_service_test.go
  • internal/services/discord_integration_test.go
  • internal/services/discord_outbound_service.go
  • internal/services/email_inbound_service.go
  • internal/services/instagram_inbound_service.go
  • internal/services/instagram_inbound_service_test.go
  • internal/services/instagram_outbound_service.go
  • internal/services/line_inbound_service.go
  • internal/services/line_inbound_service_test.go
  • internal/services/line_outbound_service.go
  • internal/services/message_service.go
  • internal/services/messenger_inbound_service.go
  • internal/services/messenger_inbound_service_test.go
  • internal/services/messenger_outbound_service.go
  • internal/services/oidc_login_service.go
  • internal/services/oidc_login_service_test.go
  • internal/services/slack_inbound_service.go
  • internal/services/slack_inbound_service_test.go
  • internal/services/slack_outbound_service.go
  • internal/services/threads_inbound_service.go
  • internal/services/threads_inbound_service_test.go
  • internal/services/threads_outbound_service.go
  • internal/services/tiktok_inbound_service.go
  • internal/services/tiktok_inbound_service_test.go
  • internal/services/tiktok_outbound_service.go
  • internal/services/user_service.go
  • internal/services/viber_inbound_service.go
  • internal/services/viber_inbound_service_test.go
  • internal/services/viber_outbound_service.go
  • internal/services/webhook_sync_service.go
  • internal/services/whatsapp_inbound_service.go
  • internal/services/whatsapp_inbound_service_test.go
  • internal/services/whatsapp_outbound_service.go
  • internal/services/x_inbound_service.go
  • internal/services/x_inbound_service_test.go
  • internal/services/x_outbound_service.go
  • internal/slack/client.go
  • internal/slack/types.go
  • internal/threads/client.go
  • internal/threads/client_test.go
  • internal/threads/types.go
  • internal/tiktok/client.go
  • internal/tiktok/types.go
  • internal/viber/client.go
  • internal/viber/client_test.go
  • internal/viber/types.go
  • internal/whatsapp/client.go
  • internal/whatsapp/types.go
  • internal/x/client.go
  • internal/x/types.go
  • qdrant
  • web/app/(dashboard)/dashboard.css
  • web/app/(dashboard)/dashboard/agents/_components/edit.tsx
  • web/app/(dashboard)/dashboard/channels/_components/edit.tsx
  • web/app/(dashboard)/dashboard/channels/page.tsx
  • web/app/(dashboard)/dashboard/conversations/_components/assignee-selector.tsx
  • web/app/(dashboard)/dashboard/conversations/_components/conversation-info-panel.tsx
  • web/app/(dashboard)/dashboard/conversations/_components/conversation-list.tsx
  • web/app/(dashboard)/dashboard/conversations/_components/conversation-workbench.tsx
  • web/app/(dashboard)/dashboard/customers/page.tsx
  • web/app/(support)/support.css
  • web/app/(support)/support/_components/support-article-content.tsx
  • web/app/(support)/typeset.css
  • web/components/channel-icon.tsx
  • web/components/customer-merge-dialog.tsx
  • web/i18n/provider.tsx
  • web/lib/api/agent.ts
  • web/lib/api/customer.ts
  • web/messages/en-US.json
  • web/messages/vi-VN.json
  • web/messages/zh-CN.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_50476133-a381-4796-9524-aeb3a5e16fb1)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive support for multiple new communication channels (Discord, Facebook Messenger, Instagram, WhatsApp, Slack, X, TikTok, LINE, Viber, and Threads) into the Crove Desk platform. It includes backend API clients, inbound webhook handlers, outbound message queues, and frontend UI updates for channel configuration. Additionally, it implements a customer profile merging feature and updates the architecture to a conversational support model. My review identified a high-severity issue regarding the accidental removal of custom email delivery settings, as well as performance concerns related to N+1 database queries in conversation and customer builders. I also noted a minor formatting issue in the architecture documentation that conflicts with the project's new formatting rules.

I am having trouble creating individual review comments. Click here to see my feedback.

web/app/(dashboard)/dashboard/channels/_components/edit.tsx (414-424)

high

The logic for saving custom email delivery settings (SMTP, API keys) has been removed from the payload construction for email channels. This means any custom SMTP or ESP configuration will be lost upon saving the channel settings. Was this intentional? If custom delivery is still a supported feature, these fields should be included in the payload.

docs/OMNICHANNEL_CONVERSATIONAL_SUPPORT_REFACTOR.md (18)

medium

The use of LaTeX math syntax $\rightarrow$ seems to violate the new formatting rule defined in .cursor/rules/user-interaction-preferences.mdc, which advises against it to prevent rendering issues. It would be better to use a standard Unicode character like or ->.

internal/builders/conversation_builder.go (48-53)

medium

This block introduces a potential N+1 query issue. The call to services.ChannelService.Get(item.ChannelID) is inside BuildConversationWithLocale, which is likely to be called within a loop when fetching a list of conversations. This would result in a separate database query for each conversation to get its channel details.

To optimize, consider fetching all required channels in a single query before the loop and then looking them up from a map, similar to the pattern used for identities in customer_builder.go.

internal/builders/customer_builder.go (97)

medium

This line introduces a potential N+1 query problem. The call to services.CompanyService.Get(item.CompanyID) is inside a loop, which will likely result in a separate database query for each customer to fetch its company details. To improve performance, it would be better to fetch all required companies in a single query before this loop and then look them up from a map inside the loop.

…nancy claim

- agent_loop_live_test.go: the hardcoded DOS.AI key fallback is replaced with t.Skip, matching dos_ai_live_test.go; the key itself must still be rotated and purged from git history (git filter-repo) - owner action

- default_kb.go: the seeded FAQ no longer implies per-workspace data isolation; it now states that conversations, tickets, customers and knowledge are shared across workspaces in one deployment
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9ad9fad2-ae1f-4300-882e-3f74558ec664)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant