Commit Graph

21 Commits

Author SHA1 Message Date
Abhinav Raut 89b40f9dac add compact webhooks endpoint and fix previous_* automation values 2026-08-06 00:17:13 +05:30
Abhinav Raut c4270f48d3 reject non-positive webhook IDs for targeted delivery
strconv.Atoi accepts "0" and negative values, and the delivery worker treats a
non-positive WebhookID as a fan out to every subscriber of the event. So a
malformed target value sent the conversation payload to unintended webhooks.
Reject it in the action and drop it in TriggerWebhook as well.
2026-08-05 22:55:09 +05:30
Abhinav Raut aa0deedd48 fix automation rule feedback loops and scope the starts with operator
An automation rule that listens on an event and then writes the same field
re-fires its own event, so the rule matches again and loops forever. Status
already returned early on a no-op write, but priority and user assignment did
not, so those two could spin a worker doing a DB write per lap. Add the same
unchanged-value guard to both.

Suppression while the engine applies actions was a plain flag in a sync.Map,
so with more than one worker on the same conversation the first one to finish
deleted the key while the other was still applying actions. Make it a refcount
so each worker releases only its own claim.

The starts with operator is only implemented by the automation evaluator, not
the SQL filter builder, so give automation text fields their own operator list
instead of adding it to the shared one.

Also switch the notify action to its own recipients field type, fix the snooze
duration hint since the backend only takes Go duration units, trim and
lowercase notify recipient entries, and treat a missing previous value as no
match rather than an empty string.
2026-08-05 18:01:20 +05:30
Abhinav Raut 2aa4a1a86e Merge branch 'main' into new-automations
# Conflicts:
#	i18n/da-DK.json
#	i18n/de-DE.json
#	i18n/es-ES.json
#	i18n/fa-IR.json
#	i18n/fr-FR.json
#	i18n/it-IT.json
#	i18n/ja-JP.json
#	i18n/mr-IN.json
#	i18n/pt-BR.json
#	internal/conversation/conversation.go
2026-08-05 16:14:06 +05:30
Abhinav Raut 178136cda5 add notify, snooze and trigger webhook automation actions 2026-08-05 16:12:55 +05:30
Abhinav Raut c7f55e2394 guard reply-box AI prompt race and share the SSRF-safe http transport
handleAiPromptSelected now captures the conversation uuid and bails if it changed while the completion was in flight, and uses convertTextToHtml with a null guard, matching handleGenerateReply. This stops a generated prompt from landing in the wrong conversation's draft or crashing on an empty response.

Add ssrf.NewTransport that clones http.DefaultTransport (keeping proxy and connection-pool defaults) and applies the dial guard, then use it for the OIDC, AI, OpenAI, and webhook clients. The bare transports were dropping HTTP_PROXY handling and pool defaults.
2026-07-18 11:20:16 +05:30
Abhinav Raut 9566dcbf4d apply SSRF guard to all admin-configured outbound URLs
Move the webhook SSRF guard into a shared internal/ssrf package and wire it
into every place the server fetches an admin-set URL: webhooks, OIDC discovery,
the AI provider base URL, and custom AI tool calls. Add a global [ssrf] config
block, off by default with an allowed_cidrs bypass, so single-tenant self-hosters
keep reaching internal hosts while multi-tenant or hosted deploys can turn it on.
The old [webhook] allowed_hosts key is still read for backward compat and folds
into the guard.
2026-07-16 12:58:12 +05:30
Abhinav Raut 33a2a877a5 Fix secret handling in webhook and context link updates, allow clearing secrets 2026-04-14 23:00:14 +05:30
Abhinav Raut 4eb5dce12c Merge branch 'main' into feat/live-chat-channel 2026-02-22 15:13:36 +05:30
Abhinav Raut 81847c7f4e i18n: fix localization issues (#231)
Not backported to main due to extensive i18n refactoring changes in this branch.
2026-02-22 15:12:00 +05:30
Abhinav Raut 727213631c SSRF protection to webhooks
- New config webhook option to allow certain CIDR ranges in webhooks.
2026-02-16 02:40:05 +05:30
Abhinav Raut b7103b24ef show oauth callback error / success messages as toast.
Add logs for errors and minor refactor
2025-12-24 16:08:25 +05:30
Abhinav Raut 2a238a719e -fix email notifications not working.
- reload app settings when notification settings are changed to trigger admin banner prompting user to restart app
- remove unncessary dummy password check before retaining passwords as an empty password check is enough.
2025-12-24 16:08:25 +05:30
Abhinav Raut 4de936da22 remove omitempty from tags
remove unused fn
2025-12-24 16:08:25 +05:30
Abhinav Raut f3ddc26512 wip inbox oauth and encryption 2025-12-24 16:08:25 +05:30
Abhinav Raut 634fc66e9f Translate welcome to libredesk email subject
- Update all SQL queries to add missing columns

- Update the create conversation API to allow setting the initiator of a conversation. For example, we might want to use this API to create a conversation on behalf of a customer, with the first message coming from the customer instead of the agent. This param allows this.

- Minor refactors and clean up

- Tidy go.mod

- Rename structs to reflect purpose

- Create focus structs for scanning JSON payloads for clarity.
2025-08-28 00:34:56 +05:30
Abhinav Raut 389c4e3dd3 fix: allow configurable webhook request timeout from config.toml 2025-07-07 00:26:31 +05:30
Abhinav Raut d2e5d85e3a fix: return created/updated objects in POST/PUT responses with masked secrets
All POST/PUT handlers now return actual database objects instead of `true`
2025-06-20 19:35:09 +05:30
Abhinav Raut 60c89cb617 use http client with set timeout for webhook requests
remove db calls from `TriggerEvent`
2025-06-14 21:48:46 +05:30
Abhinav Raut 2bf45f32de fix: remove headers field from webhook model and related queries 2025-06-14 15:03:11 +05:30
Abhinav Raut 981372ab86 wip webhooks 2025-06-13 02:17:00 +05:30