Commit Graph

100 Commits

Author SHA1 Message Date
Abhinav Raut 9f686ac568 remove redundant translations and semicolons 2026-09-25 02:06:02 +05:30
Abhinav Raut d2e2bcc3b6 Merge remote-tracking branch 'origin/main' into feat-whatsapp 2026-09-23 10:08:30 +05:30
Abhinav Raut ccba084d4b Merge remote-tracking branch 'origin/main' into libredesk-widget-improvements 2026-09-18 02:54:09 +05:30
Abhinav Raut 46e2e5250d escape wildcard characters in search queries 2026-09-18 01:04:54 +05:30
Abhinav Raut a41ce679cf merge main into WhatsApp branch 2026-09-17 00:46:54 +05:30
Abhinav Raut 89f58904d2 wip: add widget campaigns, help center in widget and transcript download 2026-09-16 02:11:44 +05:30
Abhinav Raut e8007b67fd Merge remote-tracking branch 'origin/main' into pr-312
# Conflicts:
#	frontend/apps/main/src/components/sidebar/Sidebar.vue
#	frontend/apps/main/src/features/contact/ContactsList.vue
#	internal/user/contact.go
#	internal/user/user.go
2026-09-08 01:29:04 +05:30
Abhinav Raut 8fd74635a6 Merge remote-tracking branch 'origin/main' into feat-whatsapp
# Conflicts:
#	cmd/conversation.go
#	cmd/media.go
#	cmd/messages.go
#	frontend/apps/main/src/components/sidebar/Sidebar.vue
#	frontend/apps/main/src/constants/emitterEvents.js
#	frontend/apps/main/src/features/conversation/Conversation.vue
#	frontend/apps/main/src/features/conversation/CreateConversation.vue
#	frontend/apps/main/src/features/conversation/ReplyBoxMenuBar.vue
#	frontend/apps/main/src/features/conversation/message/MessageBubble.vue
#	frontend/apps/main/src/stores/conversation.js
#	internal/conversation/models/models.go
#	internal/conversation/queries.sql
#	internal/migrations/v2.9.0.go
#	internal/search/queries.sql
#	internal/user/user.go
2026-09-03 01:37:02 +05:30
Abhinav Raut 51db29ab9d move agent lookup into its own sql queries 2026-09-01 22:45:07 +05:30
Abhinav Raut fd4a37ff76 add WhatsApp channel tests and bug fixes 2026-08-25 18:29:16 +05:30
Abhinav Raut b7c2ef93ee Merge remote-tracking branch 'origin/main' into feat-whatsapp
# Conflicts:
#	cmd/main.go
#	frontend/apps/main/src/features/conversation/Conversation.vue
#	frontend/apps/main/src/features/conversation/CreateConversation.vue
#	frontend/apps/main/src/features/conversation/list/ConversationListItem.vue
2026-08-23 03:00:22 +05:30
Abhinav Raut 71e46490a9 only upgrade the api secret hash that was just verified 2026-08-19 13:04:23 +05:30
Abhinav Raut 9708f78c79 reduce memory and cpu use in sla, static asset and api key paths
Profiled the prod alloc with pprof. Three things stood out.

SLA evaluation was refetching about 234k pending rows every 10 minutes and the
count only ever grew. A policy can leave the resolution time blank, which
stores a NULL resolution deadline. The evaluator needs a deadline to compare
against, so it could never set met_at or breached_at, and the row stayed
pending forever. The pending query now skips a metric with no deadline, and a
new set based query closes any pending row whose configured metrics have all
settled. It replaces the old per row status update, so there is one status
writer and the backlog drains itself on the first tick. No migration is needed
because nothing outside the sla package reads that status.

Static assets were copied into fasthttp's pooled per connection response
buffer on every request. That buffer keeps its grown size, so serving the
frontend bundle held about 165MB. SetBodyRaw points at the bytes instead of
copying them.

API key auth ran a full bcrypt compare on every request, which was 62 percent
of cpu samples. API secrets are 64 char random tokens, so bcrypt's work factor
buys nothing there. They are now hashed with sha256 and compared in constant
time. Old bcrypt hashes still verify and get upgraded in place on first use,
so no key needs reissuing. Password login still uses bcrypt.

This also fixes an unrelated bug the work turned up. apply-sla deleted pending
rows by status alone, so re-applying an SLA threw away a first response breach
that was already recorded. It now deletes only rows with nothing recorded and
closes the rest to their terminal status first.
2026-08-19 12:55:52 +05:30
Abhinav Raut defc6535b9 send whatsapp attachments as one message per file
Meta accepts only one media per message and sends one status webhook per
message id, so a reply with 3 files is now sent as 3 requests from the reply
box instead of one message that half-succeeded. Drops the partial-send
tracking, markers and retry-attachments button that existed to paper over it.
2026-08-16 22:51:05 +05:30
Abhinav Raut f56db191ba remove redundant comments and tighten the ones worth keeping 2026-08-16 17:04:48 +05:30
Abhinav Raut 3ef1a73bc8 Merge remote-tracking branch 'origin/main' into feat-whatsapp 2026-08-16 16:49:13 +05:30
Abhinav Raut ee6bc6ec49 add csat responses to contact export and fix download revoke 2026-08-16 13:21:37 +05:30
Abhinav Raut 5735214d1a Merge remote-tracking branch 'origin/main' into worktree-gdpr
# Conflicts:
#	cmd/upgrade.go
#	frontend/apps/main/src/views/contact/ContactDetailView.vue
#	i18n/en-US.json
#	internal/media/queries.sql
#	internal/migrations/v2.6.0.go
#	internal/user/contact.go
#	schema.sql
2026-08-15 13:17:49 +05:30
Abhinav Raut 246dd5ba00 scope external ID contact lookup to contacts only 2026-08-11 13:04:12 +05:30
Abhinav Raut f986981b44 make no-permission contact resolution race-safe in create conversation API 2026-08-11 12:08:23 +05:30
Abhinav Raut 92a1ef8150 Merge branch 'help-center' into feat-whatsapp
# Conflicts:
#	cmd/conversation.go
#	cmd/upgrade.go
#	frontend/apps/main/src/api/index.js
#	frontend/apps/main/src/constants/emitterEvents.js
#	frontend/apps/main/src/features/contact/ContactForm.vue
#	frontend/apps/main/src/features/conversation/Conversation.vue
#	frontend/apps/main/src/features/conversation/CreateConversation.vue
#	frontend/apps/main/src/features/conversation/ReplyBox.vue
#	frontend/apps/main/src/features/conversation/ReplyBoxMenuBar.vue
#	frontend/apps/main/src/features/conversation/list/ConversationListItem.vue
#	frontend/apps/main/src/features/conversation/message/MessageBubble.vue
#	frontend/apps/main/src/features/conversation/message/attachment/BubbleAttachmentItem.vue
#	frontend/apps/main/src/features/conversation/sidebar/ConversationSideBarContact.vue
#	frontend/apps/main/src/views/admin/inbox/NewInbox.vue
#	frontend/shared-ui/constants/countries.js
#	go.mod
#	internal/search/models/models.go
#	internal/stringutil/stringutil.go
#	internal/user/queries.sql
2026-07-25 14:34:00 +05:30
Abhinav Raut ab2a1471e6 log avatar delete failures and export more contact fields
Address CodeRabbit review on PR #426.

Log the error when deleting a contact's avatar file fails so a
leftover avatar (personal data) does not go unnoticed.

Add availability_status, last_active_at, last_login_at, and enabled
to the contact data export since these are personal data under GDPR
right to access.
2026-07-18 12:51:57 +05:30
Abhinav Raut bfbcd0a885 add contact deletion and data export for GDPR compliance
First part of GDPR support (#244): the right to erasure and the right
to access.

- DELETE /api/v1/contacts/{id} permanently deletes a contact or
  visitor. Conversations, messages, notes, and participants go with it
  via DB cascades. The avatar file is removed too.
- GET /api/v1/contacts/{id}/export downloads a JSON file with
  everything stored about the contact: profile, custom attributes, and
  all conversations with their messages. Private notes stay internal.
- Both actions are gated by new permissions (contacts:delete,
  contacts:export), granted to Admin in migration v2.6.0, and recorded
  in the activity log with actor and IP.
- Contact page gets Export data and Delete contact buttons, with a
  confirm dialog for delete.
- The unlinked media cleaner now also removes attachment files whose
  message no longer exists. Before this, deleting a conversation left
  its attachments on disk forever.
2026-07-14 01:30:59 +05:30
Abhinav Raut dad99bf0ee render AI agent replies as markdown and fix assistant identity, handoff, and stats bugs
Replies from the AI agent are now converted from markdown to HTML with
goldmark before queueing, so bold, links, and lists render properly in the
widget, agent app, and email. The prompt now allows simple markdown. Raw
HTML in model output is escaped by goldmark, and both frontends sanitize
on render anyway.

Other fixes bundled in:
- validate avatar type and size before creating or updating an assistant,
  and roll back the assistant if the avatar upload fails after create
- return 404 from agent update and API key endpoints for AI assistant
  identity users, and hide assistants from mention and SLA user pickers
- reserve the autonomous assistant's built-in tool names so custom tools
  cannot shadow them
- apply resolve after the reply is posted so the CSAT survey follows the
  answer instead of preceding it
- unassign the assistant on handoff even when the fallback team is the
  same team
- count reopens by status category instead of status name, and exclude
  CSAT messages from the turn cap
- split oversized wrapper divs into child blocks when chunking KB HTML
  instead of truncating them
- return 404 when soft-deleting an already-deleted agent, and keep AI
  assistants (which have no email) visible in the compact users list
2026-07-12 23:12:44 +05:30
Abhinav Raut 7186c95e40 add WIP autonomous AI agent that replies to assigned conversations
Medium (title + short body):
add WIP autonomous AI agent

New internal/aiagent package runs AI assistants that reply to customers
on conversations assigned to them, grounded on a knowledge base. Also mines
resolved conversations for FAQ suggestions. Adds admin UI and the v2.7.0
schema. Still work in progress.
2026-07-11 04:54:49 +05:30
Abhinav Raut fc71d30b8a accept phone country code in livechat JWT auth 2026-07-09 23:15:05 +05:30
Abhinav Raut 8a8d372a70 use one phone field in livechat JWT and fix phone validation 2026-07-09 02:27:08 +05:30
Abhinav Raut 8f658f274d add livechat pre-chat phone field and fix default launcher logo 2026-07-09 01:49:38 +05:30
Abhinav Raut b54a3d74fd fix WhatsApp media, status, and template bugs found in code review 2026-07-01 03:07:05 +05:30
Abhinav Raut ef80ba2fbf fix WhatsApp webhook ingestion gaps
Status events arriving before their message were silently dropped. Contacts with no email/ext_id could accumulate orphan rows on retry. Corrupt inbox configs were skipped without logging.
2026-06-27 13:33:10 +05:30
Abhinav Raut fa2b437fcd merges main into feat-whatsapp 2026-06-20 21:46:37 +05:30
Abhinav Raut 76d00c899e make the contact name upsert actually run for existing contacts 2026-06-19 04:01:56 +05:30
josephsellers 000326bbde Fix: update contact names on upsert instead of discarding them
Re-derived for the v2.x contact model. insert-contact-with-external-id
already updates names on conflict; this adds the same to
insert-contact-without-external-id, preserving existing non-empty names
via COALESCE(NULLIF(EXCLUDED.first_name, ''), users.first_name).

Without this, names from the email worker and Gravity Forms never update
existing contacts.

[Used Claude Code 🤖]
2026-06-18 11:23:42 +01:00
Abhinav Raut 1d66c3e4c2 feat: add WhatsApp Cloud API channel 2026-06-13 18:06:46 +05:30
Abhinav Raut 29881f2f82 fix: close ws stale-perm gaps and resub on reconnect
Reject disabled agents in FilterAuthorizedListUUIDs, kick role members on
permission removal or role delete, and re-sub the list and open conv on
ws reconnect using local state. Also plug the app logger into the ws
package so kicks no longer log when no connections exist.
2026-05-28 20:07:19 +05:30
Abhinav Raut a502039e59 perf: WS push for conv list, store/cache cleanups, ad-hoc UI polish
Convs and messages now push the full list-row payload to perm-authorized agents on create/assign/message, so livechat returning customers bubble up instantly without waiting for the timer refresh. Background list refresh bumped 30s ->  60s as a drift safety net.
2026-05-22 20:47:36 +05:30
Gumbraise f26df73600 Merge branch 'main' into feat/add-contact-form-and-api-route 2026-05-21 23:27:21 +02:00
Abhinav Raut edc82e9e55 refactor: drop Casbin, centralize agent cache invalidation, dedupe pending SLAs 2026-05-21 21:24:42 +05:30
Abhinav Raut 43ebed1c3a WS rewrite: per-client subscriptions and perf improvements
Targets broadcasts via per-tab list and open subs (validated at subscribe time)
instead of broadcasting message uuid to all agents. Adds frontend list typing, throttled sound,
and many perf improvements to reduce cpu memory & database queries.
Other fixes: Enforce message-to-conversation binding in handleGetMessage
2026-05-20 23:42:07 +05:30
Gumbraise db3e02760e feat(contact): add insert-contact-manual SQL query 2026-05-13 23:29:47 +02:00
Abhinav Raut 3fb75fbdde Make contact email matching deterministic and scope contact blocking to the email address 2026-04-15 12:50:55 +05:30
Abhinav Raut a644ab2e44 Scope offline status broadcasts by user type instead of broadcasting to all 2026-04-15 02:21:18 +05:30
Abhinav Raut d0a3527269 Sync contact name/email from JWT on every widget request 2026-04-01 17:15:22 +05:30
Abhinav Raut eb94f2b06b Refactor widget WS: fix concurrent writes
Update merge visitor to contact query to include other tables
Update default for continuity email config
2026-03-28 21:19:11 +05:30
Abhinav Raut 42f5a7faf5 Show ext id in contact list 2026-03-28 19:59:13 +05:30
Abhinav Raut 23e6a70844 Allow contacts with different external_user_ids to share email, add enrichment and remove email check from conversation matching 2026-03-28 12:29:44 +05:30
Abhinav Raut eb0a7b437d Add page visit tracking to widget
- fix duplicate initialization guard
- notification bell for agents
- Refactor and clean up dead code
- Fixes to pre chat form
- Add new column country to users table
- Update ratelimit pkg to be generic
2026-03-11 03:52:07 +05:30
Abhinav Raut c155fce93b feat: show contact offline / online status on sidebar
- mark contacts offline if not active for > 5 mins.
2026-01-26 03:28:34 +05:30
Abhinav Raut 70e6ebcc48 feat(widget): merge visitor to contact when new JWT is available i.e. when user logs into a an external system.
- Prevent file uploads on initial message, user send a message first to enable attachments.
- fix thumbs not loading with signature and expiry
2026-01-26 02:52:28 +05:30
Abhinav Raut 7958d7e212 Merge branch 'main' into feat/live-chat-channel 2026-01-14 00:33:51 +05:30