Commit Graph
4737 Commits
Author SHA1 Message Date
Matthew Meszaros 2af44edb50 feat: add TestLiveImport* in internal/app/contact covering the issue 207 report against real Postgres: a 1,000-row 13-column file whose custom fields are named "Company Mobile" and "Job Title" imports clean, joins its campaign and stays filterable, a bad mapping is one 400 and not a thousand row errors, the subscribed and categories columns take effect, one address listed twice becomes one contact, skipped rows still pick up the import campaign and categories without their names being erased, blank campaign and category ids are ignored while malformed ones are refused, an update never resubscribes an opted-out contact, and every row lands in exactly one of the imported/updated/skipped/failed buckets 2026-08-27 03:45:41 -07:00
Matthew Meszaros 1ba07028a4 feat: rework contactService.ImportCommit end to end so a 1,000-row 13-column upload lands: the column mapping is resolved once before any row is read (a name Warmbly cannot use, an unnamed custom column, an unknown target or a mapping with no email column is one actionable 400 instead of the same message per row, accepting both {target:"custom", custom_key} and the legacy "custom:<key>"), the subscribed column is actually applied instead of parsed and discarded and subscribed_default is confined to new contacts so an update never resubscribes someone who opted out, the categories column resolves titles to ids and creates the missing ones, a file that lists one address twice becomes one contact with the later row merged in, rows the dedup strategy skips still join the campaign and categories the import targets, campaign and category ids are canonicalised so a blank one cannot fail every row on an empty string cast to uuid[], the plan ceiling is checked once for the whole batch, and per-row notes are separated from failures so total always equals imported plus updated plus skipped plus failed; ValidateImportMapping exposes the same verdict so a saved Google Sheets sync source is rejected when it is written rather than on its next sync 2026-08-27 03:45:32 -07:00
Matthew Meszaros 242e721966 feat: extract the plan contact-ceiling check out of contactService.Add into checkContactLimit so a caller that writes in chunks can ask once for the whole batch instead of turning one plan problem into one error per row, and report the numbers (how many are being added, the plan's limit, how many the workspace already has) instead of the bare "contact limit reached for your plan" 2026-08-27 03:44:43 -07:00
Matthew Meszaros 79ceec3b32 feat: add the ContactImportTargetCustom column target so a client can say {target:"custom", custom_key:"Company Mobile"} instead of packing the name into a "custom:<key>" string, and add MaxContactImportReportedErrors with an ErrorsTruncated result flag so a 50k-row file of bad addresses reports the first thousand failures with an honest total rather than echoing the whole upload back as JSON 2026-08-27 03:44:27 -07:00
Matthew Meszaros eff67f64eb feat: add ContactRepository.ResolveCategoryNames, which maps the category titles an imported file names to the caller's category ids in one round trip and creates the missing ones at the end of their list with a palette colour, rejecting a title over 50 characters and refusing more than MaxImportCategoryNames distinct values so a free-text column mapped to Categories by mistake cannot mint a category per row 2026-08-27 03:44:17 -07:00
Matthew Meszaros ae17c8dead feat: give models.AddContact an optional Subscribed pointer and honour it in the pg_contact upsert (passed twice with explicit boolean casts because one placeholder cannot serve both the INSERT value and the DO UPDATE set without tripping Postgres parameter inference), where nil now means leave the flag alone, and stop the same upsert erasing a populated first_name, last_name, company or phone when the incoming row's cell is blank so re-importing a partial export enriches contacts instead of wiping them 2026-08-27 03:43:54 -07:00
Matthew Meszaros 66bd9e54e2 feat: route every contact custom-field write through one normalizeCustomFields helper in pg_contact so Add, Update and the bulk field editor all trim and whitespace-collapse a key before storing it and answer a bad one with the name and the rule instead of the opaque errx.ErrJSONKey, which is now unused and deleted, and bind the custom-field search filter key as a query parameter rather than interpolating it into the JSONB ->> operand now that a key can legitimately contain spaces 2026-08-27 03:43:24 -07:00
Matthew Meszaros 49234877a6 feat: widen the contact custom-field key rule in internal/utils/json.go from ^[a-zA-Z0-9_]+$ to identifier segments joined by spaces or dashes, the exact set tasks.rewriteSpacedFieldRefs already resolves, so a spreadsheet column named "Company Mobile" is storable as well as addressable as {{.Company Mobile}}, and add NormalizeJSONKey plus an exported JSONKeyRules string so every caller trims and whitespace-collapses a key identically and reports the same rule back to the user 2026-08-27 03:42:47 -07:00
Matthew Meszaros 06e5127e58 Merge pull request #213 from warmbly/fix/issue-211
Keep a mailbox in exactly one warmup pool
2026-08-27 03:41:07 -07:00
Matthew Meszaros dbe31eeb96 Merge remote-tracking branch 'origin/main' into fix/issue-211 2026-08-27 03:33:24 -07:00
Matthew Meszaros ff341b1008 Merge pull request #214 from warmbly/fix/issue-209
Fix the six admin queries that reference schema which does not exist
2026-08-27 03:28:30 -07:00
Matthew Meszaros 8b76355bf5 Merge remote-tracking branch 'origin/main' into fix/issue-211 2026-08-27 03:27:55 -07:00
Matthew Meszaros 6dea4f13cf Merge remote-tracking branch 'origin/main' into fix/issue-209 2026-08-27 03:21:31 -07:00
Matthew Meszaros 0f715da88e feat: close the force-stop race and trim the comments the review flagged: the eligibility test moved out of the admin service and into the UPDATE's WHERE clause, so a campaign that completes between the status read and the write can no longer be dragged back to paused and recorded as force-stopped, StopCampaign reports whether it actually stopped anything and the service turns a refusal into the same 400 it used to raise from the pre-check, a new live test parks the campaign at completed and at draft and fails if either is overwritten, and the explanatory comment blocks added across pg_admin.go, the admin service, the admin models and the rate-limit dialog are cut back to the one-line form CLAUDE.md asks for 2026-08-27 03:21:25 -07:00
Matthew Meszaros 4b1ccf0bed feat: keep an indefinite warmup block indefinite when migration 000097 collapses a dual membership: a blocked row carries blocked_until NULL to mean 'until an appeal succeeds', so MAX(blocked_until) skipped it as a missing value and adopted a sibling row's finite expiry, handing a permanently blocked mailbox (tampering) a release date and making it re-evaluatable by UpdateParticipantHealth, which refuses to touch a block only while blocked_until IS NULL; the merge now treats any indefinitely blocked row in the partition as the longest block there is, with a live test that an indefinite block survives a pool move, and the Go comments added by this branch are trimmed to the constraint they state 2026-08-27 03:21:08 -07:00
Matthew Meszaros 4ceb0eee1e Merge pull request #212 from warmbly/fix/issue-210
Fix leaveChannel destroying other subscribers' handlers, and balance RealtimeManager's org effect
2026-08-27 03:12:30 -07:00
Matthew Meszaros bb1f96ba79 feat: shorten the new socket lifecycle comments in SocketProvider, RealtimeManager and their channel tests to the one-line constraint-stating form CLAUDE.md asks for, since the implementation narrative they carried is already in the PR description and the regression tests 2026-08-27 03:10:36 -07:00
Matthew Meszaros 1c4fcff558 feat: make the admin panel's broken queries run: seven statements referenced schema that does not exist and failed 100% of the time, so a force-stop wrote status = 'stopped' and stopped_at to a campaign_status enum and a campaigns table that have neither, the plan writes named a duration column that became duration_id long ago, the user rate-limit read and write named a daily_email_limit column that user_rate_limits has never had, and the user preview compared email_accounts.user_id (uuid) against a text parameter and then swallowed the error so every operator saw an empty mailbox list; the same uuid = text defect in GetUserEmails, which the prepare sweep cannot see because that WHERE clause is assembled at runtime, was a live 500 on GET /admin/users/:id/emails; a stop now parks the campaign at 'paused' like the owner-facing stop and records the reason the UI has always sent and the backend has always dropped into both the audit log and the owner's campaign feed, the plan writes resolve durations.title to duration_id and answer 400 rather than a constraint violation on an unknown period, the rate-limit editor now covers the seven real limit columns instead of one that never existed and patches insert-then-update in a transaction because every column is NOT NULL, AdminWorkerEmail.LastSyncedAt is a pointer so a never-synced mailbox stops being silently dropped from every admin list, and TestLiveEveryQueryPrepares now fails on undefined columns, tables, operators and enum values instead of only reporting them 2026-08-27 03:09:40 -07:00
Matthew Meszaros cbb0b8f662 feat: keep a mailbox in exactly one warmup pool so a plan change moves it instead of leaving it in both: EnsurePoolMembership joined whichever pool the org is entitled to right now while RemovePoolMembership only ever deleted that same pool's row, so a downgraded mailbox kept its premium membership and went on being handed to paying customers as a warmup partner while every spam-score increment was counted once per row by the health evaluator; membership is now a move (one upsert keyed on the account that carries health state, block and spam score across, so changing pool cannot launder a penalty), removal is never pool-scoped, a tier change moves the participant row in the same transaction as email_accounts.warmup_pool_type, a new reconcile pass in the backend's warmup sweep evicts participants whose workspace lost warmup access and repairs pool drift for the mailboxes no warmup task ever revisits, an unreadable subscription no longer counts as "not entitled" anywhere that evicts, GetSpamScore takes the max rather than the sum and IncrementSpamScore clamps to the column ceiling instead of silently failing its CHECK, and migration 000097 merges any existing dual membership worst-wins before making one-pool-per-mailbox a unique index 2026-08-27 03:02:56 -07:00
Matthew Meszaros dc1746aa2d feat: fix the dashboard socket layer's channel bookkeeping so a topic held by two surfaces survives one of them unmounting and a workspace switch actually leaves the old organization's channel: leaveChannel deleted the whole channelsRef entry, and that entry owns the handler map, so every other subscribeToChannel registration on that topic died with it and the unsubscribe closures they held pointed at an orphaned Set, meaning the first component out silently deafened the second; it now refcounts holders in holdersRef (incremented before joinChannel's already-joined bail-out, so the second surface to ask for a live topic is actually counted) and only the last holder out leaves, resets the entry in place instead of dropping it while subscribers remain, discards it from the unsubscribe closure once nothing is listening and nobody holds the join, sends phx_leave only for a channel that was really joined or joining, and drops the pointless 'leaving' state flip that was set and nulled in the same tick and read by nothing; refcounting alone would have been actively harmful, because RealtimeManager's org effect joined with no cleanup and re-ran on every isConnected false->true cycle, so the count climbed on every reconnect and never returned to zero and switching workspaces would decrement without leaving and keep feeding the client the previous organization's events, so that effect is now balanced with a cleanup matching the user-channel effect above it and prevOrgIdRef is gone, which also fixes a latent defect of its own where switching organizations while the socket was down left the old topic in desiredTopicsRef and rejoinChannels brought the abandoned workspace back on reconnect; covered by 11 new tests over the fake-socket rig, including a real RealtimeManager mounted against the real provider, and each combination of half-fixes fails the matrix 2026-08-27 02:53:33 -07:00
Matthew Meszaros ec0a6f3b2f Merge pull request #208 from warmbly/fix/195-warmup-health-evaluation-silent-failure
fix: warmup health evaluation has never run — pgx's ErrNoRows is not sql.ErrNoRows, and UpdateParticipantHealth was never preparable (#195)
2026-08-27 01:24:55 -07:00
Matthew Meszaros 0bbfa4b2ac feat: make warmup health evaluation actually run, which it never has: GetParticipantHealth compared pgx's not-found error with == sql.ErrNoRows but pgx.ErrNoRows is a proxy that wraps it rather than being it, so "this account is not in this pool" surfaced as a hard error and the premium-first probe failed before ever reaching a free-pool account's own row; UpdateParticipantHealth used a bare $1 as both a health_state assignment and an equality test, so Postgres deduced character varying from one and text from the other and refused the statement with 42P08, meaning no health state was ever persisted for anyone in any pool; both are now fixed along with the other 18 == sql.ErrNoRows comparisons in the repository layer and the same unpreparable-parameter defect in the contacts bulk custom-field writes, the worker install-state update and the referral earnings upsert, all found by a new live test that asks Postgres to PREPARE every parameterised statement in the package; evaluation failures now log their real cause instead of collapsing into errx.InternalError, the hourly sweep reports how many participants it could not evaluate instead of skipping them in silence, ApplyInvalidTokenAttempt no longer reports failure once the attempt is persisted so the caller cannot double-count it, and migration 000096 adds a per-participant signal floor so the first working evaluation cannot block a mailbox on history gathered while nothing was watching 2026-08-27 01:04:50 -07:00
Matthew Meszaros dd1119e302 Merge pull request #204 from joaoppa/fix/195-invalid-token-double-count
fix: stop double-counting invalid warmup token attempts, and log the health evaluation failure that was being discarded (#195)
2026-08-27 00:46:59 -07:00
Matthew Meszaros c6448fecbe Merge branch 'main' into fix/195-invalid-token-double-count 2026-08-27 00:41:23 -07:00
Matthew Meszaros 08a91b39d0 Merge pull request #206 from warmbly/fix/realtime-join-throttle-and-channel-refcount
fix: throttle channel joins on the realtime service, and make both clients handle a refused join without storming it
2026-08-27 00:16:39 -07:00
Matthew Meszaros 42ddb78e60 feat: make the realtime service survive a client that spams channel joins, and stop both clients from being that client: ws_join is now spent per phx_join in a shared RealtimeWeb.ChannelGuard that every channel runs BEFORE its Auth lookup (it was only ever spent on the socket handshake, so an established socket could issue unlimited joins and each one cost a Postgres query), handshakes move to their own ws_connect bucket so a reconnect storm cannot eat the budget a client needs to rejoin with, the retry_after_ms hint now points at the next window instead of shrinking as overage grew, every channel's join rejection carries the numeric code the API reference already promised (plus 4005 for a malformed topic), BulkChannel only pushes an event to the user who owns the operation instead of to anyone who guesses the id, and the web and admin clients treat a rate_limited join as transient (wait out the hint, keep the socket) while backing off per-channel rejoins on a decaying schedule rather than reconnecting on the 120ms floor forever; adds an ExUnit suite for realtime and a vitest suite for admin, both wired into CI 2026-08-26 21:14:34 -07:00
Matthew Meszaros 49e1696011 Merge pull request #205 from joaoppa/fix/socket-channel-rejoin-loop
fix: stop the realtime socket rejoining a channel on every render (~400 joins/second from one open campaign page)
2026-08-26 20:51:42 -07:00
joao-crm f82e3c3402 feat: stop the realtime socket tearing down and rejoining a channel on every render, which made one open campaign page issue about 400 channel joins per second and saturate the realtime service: the provider's context value is now memoised instead of an inline object literal, and useChannel/useChannelEvent depend on the stable joinChannel/leaveChannel/subscribeToChannel callbacks and on params BY VALUE rather than on the whole context, so channelStates re-rendering the provider no longer re-runs the effect that owns the subscription 2026-08-27 03:05:15 +00:00
joao-crm 9130498ade feat: stop double-counting every invalid warmup token attempt by treating a failed health evaluation as non-fatal inside ApplyInvalidTokenAttempt, since the attempt and its spam score are already persisted when it runs and the caller's degraded path recorded both a second time, and log the evaluation failure that was being discarded so the band that never fired can finally be diagnosed 2026-08-26 23:05:52 +00:00
Matthew Meszaros 28fbde314d Merge pull request #203 from warmbly/fix/issue-200-investigation
fix: one undeliverable address no longer wedges a whole campaign, and the pre-send verifier stops inventing the verdict that caused it
2026-08-26 06:10:04 -07:00
Matthew Meszaros 0a8c3314d0 feat: stop one undeliverable address from wedging a whole campaign, and stop the pre-send verifier from inventing the verdict that caused it: campaign routing in FindNextRoutedPair now excludes contacts whose address verification refused them (invalid, or risky with the campaign's send-to-risky toggle off) because the pre-send gates in campaign_task.go skip those without recording progress, so the finder re-served the same lead every tick and the campaign never reached the healthy leads behind it; the SMTP prober no longer reads every 5xx reply to RCPT TO as a dead mailbox, since Postfix defers HELO/sender/policy rejections to RCPT time and the old default greeting of localhost made them arrive as 504 5.5.2 Helo command rejected against the recipient, so a 5xx now becomes invalid only when the reply names the recipient and degrades to unknown otherwise; the HELO name falls back to the APP_URL host and the probe is skipped outright without a public FQDN; migration 000095 resets the verdicts the corrected classifier would no longer reach so poisoned contacts are re-verified; and skipped leads now report as undeliverable in the Leads view and in the campaign completion log instead of sitting at Queued forever 2026-08-26 06:03:20 -07:00
Matthew Meszaros a9ff56d2c5 Merge pull request #202 from warmbly/chore/remove-stray-repo-files
chore: remove stray, unreferenced files from the repository
2026-08-26 05:02:22 -07:00
Matthew Meszaros 8953b2a132 chore: delete repository junk that was never referenced by anything: the paseo worktree-tool config, the root .astro type output an astro run from the repo root left behind, the empty schema.sql, the stray root package.json plus pnpm-lock.yaml from an accidental pnpm add motion (every frontend tree owns its own manifest and lockfile, and CI only ever reads those), the zero-byte cmd/consumer/envsample, the empty web CampaignSearchProvider.tsx, six Go files holding nothing but a package clause, and models.WMailAdd which had no callers; root .gitignore now covers each of them so they cannot drift back in 2026-08-26 04:55:45 -07:00
Matthew Meszaros 51fec3dd44 Merge pull request #201 from warmbly/placid-ridge
fix: verify warmup mail whose verify header Graph stripped in transit
2026-08-26 04:40:43 -07:00
Matthew Meszaros b77664cd09 feat: verify warmup mail that arrives without its verify header, because Microsoft Graph strips custom headers in transit and re-stamps the Message-ID, so every warmup email sent from an Outlook or Microsoft 365 mailbox reached its recipient unmarked, consumed no token, earned no engagement and was filed in the recipient's unibox as ordinary mail; the Graph client now creates the message as a draft and sends that so it can read the internetMessageId Exchange assigned, the consumer records that delivered id on the task and its warmup token alongside the sent subject, and the recipient resolves an unmarked warmup email by delivered Message-ID or by the pending sender/recipient/subject pair 2026-08-26 04:31:19 -07:00
Matthew Meszaros 6b00ab23cb Merge pull request #199 from warmbly/fix/graph-spam-rescue-guard
fix: Graph rescues a message from Junk that was never in Junk, undoing the Warmbly foldering and re-ingesting the message
2026-08-25 20:40:07 -07:00
Matthew Meszaros f1856749e4 feat: only rescue a Graph message from Junk when it is actually in Junk, because engagementPlan folders into the untracked Warmbly folder first and the unconditional move undid that foldering and dropped the message back into the tracked Inbox under a new id, where live sync re-ingested it as new mail and burned its already-consumed warmup token as an invalid-token attempt 2026-08-25 20:14:22 -07:00
Matthew Meszaros 4c9d0b1c87 Merge pull request #198 from joaoppa/fix/186-warmup-selfmove-and-namespace
fix: stop banning a warmup recipient for the foldering we ordered, and create the Warmbly folder inside the server's IMAP namespace (#186)
2026-08-25 20:07:15 -07:00
Matthew Meszaros c65d083545 Merge branch 'main' into fix/186-warmup-selfmove-and-namespace 2026-08-25 20:01:11 -07:00
Matthew Meszaros 35ca9967cf Merge pull request #197 from joaoppa/fix/181-warmup-generation-schema
fix: make warmup AI generation work at all, and report the provider's real reason when a batch fails (#181)
2026-08-25 19:57:48 -07:00
joao-crm 8752b02217 feat: create and move into the Warmbly folder inside the server's personal IMAP namespace instead of the root, so Dovecot hosts that keep user folders under INBOX. stop failing every warmup foldering action with "nonexistent namespace" and silently losing that engagement signal 2026-08-25 20:47:15 +00:00
joao-crm 135e0c8c94 feat: stop banning a warmup recipient for the foldering the platform itself ordered, by marking each move_to_warmbly before it is published and excusing the single removal it produces, since Microsoft Graph reports a move out of a tracked folder exactly like a deletion and the tampering threshold of one blocked every Outlook mailbox on its first warmup email 2026-08-25 20:46:37 +00:00
joao-crm ac40eca920 feat: read a fully failed batch's error file instead of reporting "empty output file id", so a generation job that had every request refused names the provider's actual reason in the admin panel rather than an internal guard message 2026-08-25 20:46:27 +00:00
joao-crm 93a2fa0962 feat: reflect the structured-output schema inline and anonymously so OpenAI stops rejecting every warmup generation request with "$ref cannot have keywords {'$id'}", which made AI warmup content impossible to generate on any install 2026-08-25 20:46:27 +00:00
Matthew Meszaros c9f831c59a Merge pull request #192 from warmbly/feature/issue-185-implementation
Add Delete and Duplicate campaign actions to the dashboard
2026-08-25 09:08:36 -07:00
Matthew Meszaros 6ebc925a93 feat: fix the campaigns guide so the docs site builds again: the new Duplicate and delete section wrote the derived copy name as "<name> (copy)", which MDX parses as an unclosed JSX tag and fails the Cloudflare Pages build; it is now inline code 2026-08-25 09:02:05 -07:00
Matthew Meszaros d396f53fc4 feat: add Delete and Duplicate campaign actions to the dashboard (issue #185): every campaign row and the detail header get a ⋯ menu (Edit, Duplicate, Start/Pause, Delete) plus a Delete card at the bottom of Settings, all permission-gated with a confirm that spells out what goes; DELETE /campaigns/:id is now organization-scoped instead of user_id-scoped so teammates can delete, runs in one transaction that also deletes the campaign's pending tasks and cancels a wakeup tick claimed at that moment (campaign_tasks only nulls its link, so those rows kept firing), removes attachment objects and publishes CAMPAIGN_DELETED so a teammate's open detail page is sent back to the list; new POST /campaigns/:id/duplicate copies the campaign row as a draft with steps and their branch graph rewired onto new step ids, tags, folders, senders with rotation reset, A/B variants, advanced settings and attachments (quota-checked, blobs undone if the copy fails) and none of the leads, progress, logs, counters, ramp level, guardrail trip or past dates, naming it (copy)/(copy N) inside the 50 byte cap without splitting runes; a claimed campaign tick whose campaign vanished now ends the chain instead of staying active forever; covered by TestLiveCampaignLifecycle* against real SQL, RemapBranchTargets and duplicateName unit tests and a react-query vitest for the list cache, with API reference, endpoint map and campaigns guide updated 2026-08-25 08:54:51 -07:00
Matthew Meszaros 5da840ba72 Merge pull request #191 from warmbly/fix/issue-187
fix: adding a contact to a campaign actually creates the lead and shows it on the Leads tab
2026-08-25 08:04:24 -07:00
Matthew Meszaros 560776619c feat: fix adding a contact to a campaign so the lead is actually created and shows up on the campaign Leads tab: contact writes matched campaign membership on campaigns.user_id, so a member adding a contact to a campaign a teammate created selected no rows and the API answered 200 having done nothing, and GetDetail rendered the contact 360 through the same filter so existing memberships read as empty; Update, Add and the GetDetail badge subselect now scope on organization_id, the membership diff runs as one statement per direction with UUID-validated ids, and the response always re-reads membership so an unrelated field edit no longer returns campaigns:null; on the dashboard the Leads tab is a ["contacts","list"] search scoped to one campaign, and useUpdateContactsBulk patched rows under a ["campaigns","list"] key that holds no contacts and invalidated nothing, so the cached lead-less result survived its 5 minute staleTime and only a search (a new query key) appeared to find the contact, so every contact mutation hook now invalidates ["contacts"] and ["campaigns"] from onSuccess, covered by TestLiveContact* against real SQL and a react-query test that fails on the old hooks 2026-08-25 07:55:15 -07:00
Matthew Meszaros 9f5b4499b1 Merge pull request #190 from warmbly/fix/issue-189-image-review-fixes
fix: campaign stuck at "Queued / Not started" with nothing sending (#189)
2026-08-25 07:45:08 -07:00