diff --git a/cmd/consumer/main.go b/cmd/consumer/main.go index 8fb3e5240..ea9fc7e68 100644 --- a/cmd/consumer/main.go +++ b/cmd/consumer/main.go @@ -580,6 +580,7 @@ func main() { AdminRepo: repository.NewAdminRepository(primaryDB.Pool), AssignmentService: workerAssignmentSvc, Notifier: notificationService, + UniboxAccess: feature.NewService(subscriptionRepoConsumer, planRepoConsumer), OpsNotifier: opsNotifierC, TaskRepo: taskRepo, CampaignRepo: campaignRepo, diff --git a/docs/content/docs/api/endpoints.mdx b/docs/content/docs/api/endpoints.mdx index 8b26689e6..68f4a3d87 100644 --- a/docs/content/docs/api/endpoints.mdx +++ b/docs/content/docs/api/endpoints.mdx @@ -275,7 +275,7 @@ The `/unibox/drafts` endpoints hold autosaved compose drafts, scoped to the call `POST /emails/:id/hold` keeps a mailbox out of campaign sending until `POST /emails/:id/release` puts it back; warmup is unaffected and the automatic rest logic never releases a hold. `release` is also the manual exit for a mailbox that is `resting` automatically. Both are bodyless and idempotent, so they take no `Idempotency-Key`. See [holding a mailbox yourself](/guides/mailboxes/#holding-a-mailbox-yourself). -`GET /emails/allowance` reports how many mailboxes the workspace holds (`used`), how many it may hold (`allowance`, `null` for unlimited), `remaining`, and the `basis` of the number: `fair_use` (the plan's daily sends divided by `sends_per_mailbox`), `plan`, `override` (an approved request), `free`, or `unlimited`. `pending_request` is the open limit-increase request for mailboxes, if any. Every connect path refuses with `mailbox_allowance_reached` once `remaining` is `0`. See [mailbox allowance](/guides/mailboxes/#mailbox-allowance). +`GET /emails/allowance` reports how many mailboxes the workspace holds (`used`), how many it may hold (`allowance`, `null` for unlimited), `remaining`, and the `basis` of the number: `fair_use` (the plan's daily sends divided by `sends_per_mailbox`), `plan`, `override` (an approved request), `free` (no paid plan: `0`, or `10` for a workspace that kept the earlier free plan), or `unlimited`. `pending_request` is the open limit-increase request for mailboxes, if any. Every connect path refuses with `mailbox_allowance_reached` once `remaining` is `0`. See [mailbox allowance](/guides/mailboxes/#mailbox-allowance). `GET /emails/:id/identity` reports which addresses the mailbox's provider will let it send as, which one it uses, and whether its signature was imported or written here; it contacts no provider. `POST /emails/:id/identity/refresh` re-reads that list from the provider and stores it, and with `import_signature` also replaces the stored signature with the one configured at the provider. Storing the list is what a `send_as_email` choice is validated against, so the refresh needs `WRITE_EMAILS` rather than `READ_EMAILS`; it takes no `Idempotency-Key` because it writes exactly what the provider currently says. Gmail only. See [sending identity](/guides/mailboxes/#sending-identity). diff --git a/docs/content/docs/api/error-codes.mdx b/docs/content/docs/api/error-codes.mdx index fec4a33bf..78c9ea241 100644 --- a/docs/content/docs/api/error-codes.mdx +++ b/docs/content/docs/api/error-codes.mdx @@ -1070,7 +1070,7 @@ Those request URLs answer `401` `unauthorized` to a request whose Slack signatur #### `mailbox_allowance_reached` -A `403` whose `code` is `mailbox_allowance_reached` comes from every path that connects a mailbox: `POST /emails/onboarding/oauth/start`, `POST /emails/onboarding/oauth/finish`, `POST /emails/onboarding/smtp-imap`, and per row inside `POST /emails/onboarding/smtp-imap/bulk`. A [mailbox import](/guides/mailbox-import/) does not answer it over HTTP: the rows past the allowance fail with the `cause` `allowance_reached` and can be retried once it is raised. It is not a permission problem: the workspace holds its whole [mailbox allowance](/guides/mailboxes/#mailbox-allowance), which on a paid plan is one mailbox for every send a day the plan includes, and `10` on a free workspace. Nothing was connected. +A `403` whose `code` is `mailbox_allowance_reached` comes from every path that connects a mailbox: `POST /emails/onboarding/oauth/start`, `POST /emails/onboarding/oauth/finish`, `POST /emails/onboarding/smtp-imap`, and per row inside `POST /emails/onboarding/smtp-imap/bulk`. A [mailbox import](/guides/mailbox-import/) does not answer it over HTTP: the rows past the allowance fail with the `cause` `allowance_reached` and can be retried once it is raised. It is not a permission problem: the workspace holds its whole [mailbox allowance](/guides/mailboxes/#mailbox-allowance), which on a paid plan is one mailbox for every send a day the plan includes, `0` on a workspace without a paid plan, and `10` on a workspace that kept the earlier free plan. On a workspace without a plan the message says a plan is needed to connect mailboxes. Nothing was connected. ```json { @@ -1083,6 +1083,7 @@ A `403` whose `code` is `mailbox_allowance_reached` comes from every path that c **How to fix:** - Read `GET /emails/allowance` first: `remaining` says how many connects will succeed, and `pending_request` whether an increase is already asked for +- Without a paid plan, choose one: every paid plan connects mailboxes - Submit a limit-increase request for `max_email_accounts` via `POST /organization/:orgId/limit-requests`, or move to a plan with more daily sends. An approved request raises the allowance immediately; retry the connect then - Reconnecting an existing mailbox never returns this code diff --git a/docs/content/docs/development/install.mdx b/docs/content/docs/development/install.mdx index 94b595922..24eaec374 100644 --- a/docs/content/docs/development/install.mdx +++ b/docs/content/docs/development/install.mdx @@ -18,7 +18,7 @@ curl -fsSL https://warmbly.com/install.sh | sh -s -- --wizard You do not have to remember the flag. A fresh install with a terminal in front of it and no hostname given asks whether to configure itself before it writes anything, because the alternative is an instance on `localhost`: a dashboard, a tracking host and an unsubscribe address that work from that machine and nowhere else, all of which end up inside campaign mail. Answer no and it says so plainly and carries on. `--assume-yes`, `--host`, `WARMBLY_HOST` and a re-run over an existing install all skip the question, because each of them already answered it. -Self-hosting is for experienced operators. Warmbly provides no support for self-hosted instances; the community helps on [Discord](https://dc.warmbly.com). Warmup between an instance's own mailboxes works but is not effective. For a warmup pool of thousands of real mailboxes, use Warmbly Cloud on [app.warmbly.com](https://app.warmbly.com), which means keeping those mailboxes in a hosted workspace: Warmbly Cloud no longer links new self-hosted instances. A new instance registers its own [Google and Microsoft OAuth apps](/development/deployment-guide/#connect-mailboxes) and serves its own [root redirects](/guides/sending-domains/#root-redirects). +Self-hosting is for experienced operators. Warmbly provides no support for self-hosted instances; the community helps on [Discord](https://dc.warmbly.com). Warmup between an instance's own mailboxes works but is not effective. For a warmup pool of thousands of real mailboxes, use Warmbly Cloud on [app.warmbly.com](https://app.warmbly.com), which means keeping those mailboxes in a hosted workspace on a paid plan: Warmbly Cloud no longer links new self-hosted instances. A new instance registers its own [Google and Microsoft OAuth apps](/development/deployment-guide/#connect-mailboxes) and serves its own [root redirects](/guides/sending-domains/#root-redirects). ## What it installs diff --git a/docs/content/docs/guides/billing.mdx b/docs/content/docs/guides/billing.mdx index 836517ec3..d40b4a7bc 100644 --- a/docs/content/docs/guides/billing.mdx +++ b/docs/content/docs/guides/billing.mdx @@ -3,7 +3,7 @@ title: Plans and billing description: How plans unlock features, how to upgrade from anywhere in the dashboard, and what changes when you switch. --- -Every hosted workspace starts free. A paid plan turns on sending from Warmbly Cloud, the unified inbox, contacts, the CRM, automations and integrations. +Signing up for a hosted workspace is free, and so is looking around the dashboard. Connecting and warming mailboxes needs a paid plan, which also turns on sending from Warmbly Cloud, the unified inbox, contacts, the CRM, automations and integrations. ![Settings > Billing: the plan card, usage against limits, and the subscription actions](/guides/billing.webp) @@ -33,18 +33,23 @@ With no subscription yet, finish in Stripe Checkout. An existing subscription sw ## Good to know -- The free workspace warms up to 10 mailboxes. +- A new workspace without a paid plan cannot connect or warm mailboxes. Paid plans start at $29 a month with unlimited mailboxes and unlimited warmup in the premium pool. +- A workspace that already had the free plan keeps it: up to 10 mailboxes warming in the free pool, no card and no time limit. - Annual billing is 20% off the monthly price. - Only the workspace owner can change the plan. -- Cancelling keeps the plan active until the end of the paid period, and the workspace keeps its mailboxes, warmup and settings. +- Cancelling keeps the plan active until the end of the paid period. The workspace keeps its mailboxes and settings after that, and warmup stops until it picks a plan again. - The Warmup plan is no longer sold. A workspace already on it keeps it while it stays subscribed. - Some plans, like the Partnership plan, are private and can be bought only once Warmbly has [offered them](#plans-offered-to-a-workspace) to your workspace. -## What the free workspace includes +## Without a paid plan -Every hosted workspace starts free. The free workspace warms up to 10 mailboxes connected on the cloud. Warmbly Cloud no longer links new self-hosted instances on any plan; a free workspace [linked earlier](/guides/warmbly-cloud/#free-workspaces-linked-earlier) keeps what it already enrolled but adds no new mailboxes until it picks a plan. Sending from Warmbly Cloud, the unified inbox, contacts, the CRM, automations and integrations turn on with a paid plan. +Warmbly Cloud has no free plan for new workspaces. Anyone can sign up and explore the dashboard, but a workspace without a paid plan has a [mailbox allowance](/guides/mailboxes/#mailbox-allowance) of `0`: connecting a mailbox is refused with [`mailbox_allowance_reached`](/api/error-codes/#mailbox_allowance_reached), and no warmup is scheduled. Choosing any plan lifts both. + +Workspaces that had the free plan before it closed to new workspaces keep it, unchanged, for as long as they like: up to 10 mailboxes connected on the cloud, warming in the free pool, with no card. Subscribing moves those mailboxes to the premium pool with no cap. Warmbly Cloud no longer links new self-hosted instances on any plan; a free workspace [linked earlier](/guides/warmbly-cloud/#free-workspaces-linked-earlier) keeps what it already enrolled but adds no new mailboxes until it picks a plan. Sending from Warmbly Cloud, the unified inbox, contacts, the CRM, automations and integrations turn on with a paid plan. + +A [self-hosted instance](/development/install/) has no billing and no allowance: every mailbox connects and warms. Its warmup only pairs the mailboxes on that instance, with no shared pool, so it does far less for deliverability than warming on Warmbly Cloud. Self-hosting suits teams that want to own the whole stack. @@ -106,8 +111,8 @@ Only the workspace owner can change the plan. Other members see the same compari **Overview** is the control panel for the subscription. - The plan card shows the plan, its status, the price (per year on a yearly subscription), and the renewal or end date. Change plan opens the same chooser the locked features use. -- Cancel plan schedules the cancellation for the end of the paid period. The plan stays fully active until then, and Resume clears it with one click. Nothing is lost either way: the workspace returns to the free tier and keeps its mailboxes, warmup and settings. -- Usage and limits shows live counts against the limits the server actually enforces, for mailboxes, sends today (the cap the sender applies, or unlimited on a plan without one), contacts, campaigns, team members, attachment storage, sends this period, and API calls. A meter turns amber past 70% and red past 90%. A meter with no cap means that limit is unmetered on your plan. A workspace that does not send (free, or on the Warmup or Partnership plan) sees only the mailbox meter, because none of the others applies to it. The mailbox meter says where its number comes from (fair use, an approved request, or the free allowance), and the storage meter says so when a plan change left the workspace over its quota: existing attachments keep sending, and new uploads wait until you are back under. +- Cancel plan schedules the cancellation for the end of the paid period. The plan stays fully active until then, and Resume clears it with one click. Nothing is deleted either way: the workspace keeps its mailboxes and settings, and warmup stops until it picks a plan again (a workspace that kept the earlier free plan returns to it). +- Usage and limits shows live counts against the limits the server actually enforces, for mailboxes, sends today (the cap the sender applies, or unlimited on a plan without one), contacts, campaigns, team members, attachment storage, sends this period, and API calls. A meter turns amber past 70% and red past 90%. A meter with no cap means that limit is unmetered on your plan. A workspace that does not send (free, or on the Warmup or Partnership plan) sees only the mailbox meter, because none of the others applies to it. The mailbox meter says where its number comes from (fair use, an approved request, or the free allowance, which is `0` for a new workspace without a plan), and the storage meter says so when a plan change left the workspace over its quota: existing attachments keep sending, and new uploads wait until you are back under. - Banners appear only when something needs a decision: a failed payment, a scheduled cancellation, or a trial about to end. Need a single limit raised without moving plan? Request an increase from **Settings > Limits**, linked from the usage section, or straight from the connect dialog when it is mailboxes you need. An operator reviews it and the approved limit takes effect on the workspace, including the daily send allowance the sender enforces. The page shows how much of each limit the workspace uses, and a limit your plan leaves unlimited (mailboxes, on a plan whose daily sends are uncapped) is not offered, because there is nothing to raise. A workspace that does not send can only ask for more mailboxes. @@ -136,7 +141,7 @@ Upgrading a workspace with only a managed plan opens Checkout to create a Stripe Operators grant one from the admin panel on the workspace, under **Plan**. The organization list marks granted workspaces with a `managed` badge and can filter to them, so "who is paid because we said so" is answerable without checking Stripe. A grant that has lapsed keeps its reason on file and is shown as `grant lapsed` rather than disappearing. -A grant is held beside the plan a workspace pays for, never on top of it, so a paying workspace that is granted a different plan goes back to the one it pays for when the grant ends. Revoking returns the workspace to whatever it actually pays for, which for most is the free plan. +A grant is held beside the plan a workspace pays for, never on top of it, so a paying workspace that is granted a different plan goes back to the one it pays for when the grant ends. Revoking returns the workspace to whatever it actually pays for, which can be no plan at all. One thing a grant does not do: monthly AI credits are granted when an invoice is paid, and a granted plan raises no invoice, so a managed workspace does not receive a recurring credit allowance. Top up its balance directly if it needs credits. diff --git a/docs/content/docs/guides/mailboxes.mdx b/docs/content/docs/guides/mailboxes.mdx index 9438bc961..48cbfe9f7 100644 --- a/docs/content/docs/guides/mailboxes.mdx +++ b/docs/content/docs/guides/mailboxes.mdx @@ -243,7 +243,8 @@ Mailboxes are unlimited on every paid plan. What keeps that honest is a fair-use | Plan | Sends per day | Mailboxes | | --- | --- | --- | -| Free workspace | none | `10` | +| No paid plan | none | `0` | +| Free plan kept from before | none | `10` | | Starter | `150` | `150` | | Grow | `3,000` | `3,000` | | Business | `15,000` | `15,000` | @@ -251,7 +252,7 @@ Mailboxes are unlimited on every paid plan. What keeps that honest is a fair-use That is deliberately far more than safe sending ever needs: at the recommended `30` to `50` sends a day per mailbox, a Business workspace fills its volume with a few hundred mailboxes and still has room for tens of thousands. The allowance exists so that it is never the reason to run a mailbox hotter. A plan whose daily sends are uncapped holds unlimited mailboxes, and a self-hosted instance without billing never counts. -**A free workspace.** Subscribe to any plan to warm more than `10` mailboxes here. A [self-hosted instance](/development/install/) has no mailbox cap, but its warmup only pairs its own mailboxes and Warmbly Cloud no longer links new instances, so the hosted pool is only reached from a hosted workspace. +**Without a paid plan.** A new workspace connects no mailboxes until it picks a plan; the connect is refused with [`mailbox_allowance_reached`](/api/error-codes/#mailbox_allowance_reached). A workspace that had the free plan before it closed to new workspaces keeps `10` mailboxes warming in the free pool; subscribe to any plan to hold more. A [self-hosted instance](/development/install/) has no mailbox cap, but its warmup only pairs its own mailboxes, with no shared pool, so it does far less for deliverability. Warmbly Cloud no longer links new instances, so the hosted pool is only reached from a hosted workspace. The connect dialog shows the allowance up front: a quiet count while there is room, a warning near the cap, and a clear full state that leads to the request flow instead of letting you type credentials that would be refused. When a connect is refused the answer is the same dialog, not an error toast. @@ -527,7 +528,7 @@ Keep warmup running after campaigns begin rather than switching it off once a ma A mailbox marked as a [placement seed inbox](/guides/placement-tests/#your-own-seed-inboxes) is the exception: it never warms up (starting warmup on it is refused until it is unmarked) and never sends campaign mail, because a test inbox has to stay a stranger to your senders. - The model still supports separate free and premium pools, but access is gated to paid workspaces today. + On Warmbly Cloud every paid plan warms in the premium pool. Only a workspace that had the free plan before it closed to new workspaces warms without one, up to `10` mailboxes in the free pool. diff --git a/docs/content/docs/guides/warmbly-cloud.mdx b/docs/content/docs/guides/warmbly-cloud.mdx index 9eea812e4..47fd1e4ea 100644 --- a/docs/content/docs/guides/warmbly-cloud.mdx +++ b/docs/content/docs/guides/warmbly-cloud.mdx @@ -95,7 +95,7 @@ A free Cloud workspace that already has a linked instance keeps it, and every ma That connection adds no new mailbox to Cloud until the workspace subscribes to a paid Warmbly Cloud plan. Enrolling an SMTP/IMAP mailbox, signing in a Google or Microsoft mailbox through Warmbly Cloud, and connecting an existing Cloud workspace mailbox into the instance are refused with `pool_link_subscription_required` (402). New mailboxes warm locally on the instance instead. It follows that a mailbox you unenroll cannot be enrolled again without the plan. -**Settings > Warmbly Cloud** shows how many mailboxes the workspace keeps, and the **Mailboxes** page says when new ones warm locally, with a **See plans** button. Moving the linked Cloud workspace to a paid plan lifts the restriction on the existing connection; nothing needs reconnecting. This applies only to linked instances: a free workspace still warms up to 10 mailboxes connected directly on Warmbly Cloud. +**Settings > Warmbly Cloud** shows how many mailboxes the workspace keeps, and the **Mailboxes** page says when new ones warm locally, with a **See plans** button. Moving the linked Cloud workspace to a paid plan lifts the restriction on the existing connection; nothing needs reconnecting. This applies only to linked instances: a workspace that kept the free plan still warms up to 10 mailboxes connected directly on Warmbly Cloud. A new workspace has no free plan to keep and needs a paid plan to connect mailboxes; see [billing](/guides/billing/#without-a-paid-plan). Deploy the Cloud backend before upgrading self-hosted instances. Older self-hosted versions keep working against it; on a free workspace they show the refusal when they try to add a mailbox. diff --git a/docs/content/docs/guides/warmup.mdx b/docs/content/docs/guides/warmup.mdx index fb7dc494b..40f1c7e40 100644 --- a/docs/content/docs/guides/warmup.mdx +++ b/docs/content/docs/guides/warmup.mdx @@ -39,7 +39,8 @@ Pause to stop both sending and receiving warmup mail, or Stop to also turn diagn ## Good to know -- Warmup is a paid feature: free organizations can connect mailboxes, but no warmup traffic is scheduled for them. +- On Warmbly Cloud, warmup needs a paid plan, and every paid plan warms unlimited mailboxes in the premium pool. A workspace that had the free plan before it closed to new workspaces keeps warming up to 10 mailboxes in the free pool. +- A self-hosted instance warms every mailbox, but only against the other mailboxes on that instance, with no shared pool. - New mailboxes start with warmup off. Once on, it starts at `10` emails a day by default and climbs by `+1` a day to a ceiling of `40`. - Keep warmup on after campaigns start. A mailbox backing a live campaign drops to at most five warmup messages a day, and the pool replies to more of them. - Warmup mail never appears in the unibox, and it is removed from the mailbox after 30 days by default. @@ -52,7 +53,7 @@ Pause to stop both sending and receiving warmup mail, or Stop to also turn diagn Warmup sends natural plain-text threads between participating mailboxes. It measures observed placement and bounded actual-message DKIM evidence. It does not establish organic engagement or guarantee reputation improvement or inbox placement. - Free organizations can connect mailboxes, but no warmup traffic is scheduled for them; pending warmup activity is skipped rather than sent. + On Warmbly Cloud a workspace without a paid plan cannot connect mailboxes, and no warmup traffic is scheduled for it; pending warmup activity is skipped rather than sent. A workspace that had the free plan before it closed to new workspaces keeps warming up to 10 mailboxes in the free pool. See [billing](/guides/billing/#without-a-paid-plan). @@ -124,7 +125,7 @@ A pool is the set of mailboxes that warm each other. Your mailbox exchanges warm | Pool | Who is in it | |------|--------------| | `premium` | Paid organizations' mailboxes. The default for paid accounts, isolated from lower-trust traffic. | -| `free` | Lower-trust or trial mailboxes, kept separate so free traffic does not mix into premium reputation. | +| `free` | Mailboxes of workspaces that kept the earlier free plan, and lower-trust mailboxes, kept separate so free traffic does not mix into premium reputation. New workspaces do not join it without a plan. | A mailbox belongs to exactly one pool at a time. When its plan changes the mailbox moves between pools rather than joining a second one, and it takes its warmup standing with it, so a quarantine or block is not cleared by changing tier. diff --git a/internal/app/consumer/action_required_notify_test.go b/internal/app/consumer/action_required_notify_test.go index 28bb97419..20d0ead35 100644 --- a/internal/app/consumer/action_required_notify_test.go +++ b/internal/app/consumer/action_required_notify_test.go @@ -8,6 +8,7 @@ import ( "github.com/google/uuid" + "github.com/warmbly/warmbly/internal/errx" "github.com/warmbly/warmbly/internal/models" ) @@ -73,3 +74,39 @@ func TestNotifyActionRequiredWithoutNotifierIsQuiet(t *testing.T) { s := &JobsService{} s.notifyActionRequired(uuid.New(), "", &models.EmailMessageStoreData{ID: uuid.New()}) } + +type fixedUnibox struct { + ok bool + xerr *errx.Error +} + +func (f fixedUnibox) CanUseUnibox(context.Context, uuid.UUID) (bool, *errx.Error) { + return f.ok, f.xerr +} + +// A workspace whose plan locks the inbox gets no notice pointing into it; an unknown answer still notifies. +func TestNotifyActionRequiredFollowsInboxAccess(t *testing.T) { + for _, tc := range []struct { + name string + gate fixedUnibox + want bool + }{ + {"inbox locked", fixedUnibox{ok: false}, false}, + {"inbox open", fixedUnibox{ok: true}, true}, + {"access unknown", fixedUnibox{xerr: errx.New(errx.Internal, "down")}, true}, + } { + n := &captureOrgNotifier{got: make(chan capturedOrgNotice, 1)} + s := &JobsService{Notifier: n, UniboxAccess: tc.gate} + s.notifyActionRequired(uuid.New(), "[EMAIL]", &models.EmailMessageStoreData{ID: uuid.New(), ThreadID: "t"}) + select { + case <-n.got: + if !tc.want { + t.Errorf("%s: notified, want silent", tc.name) + } + case <-time.After(300 * time.Millisecond): + if tc.want { + t.Errorf("%s: silent, want a notice", tc.name) + } + } + } +} diff --git a/internal/app/consumer/event_new_email.go b/internal/app/consumer/event_new_email.go index 24f1af352..fa3c254d6 100644 --- a/internal/app/consumer/event_new_email.go +++ b/internal/app/consumer/event_new_email.go @@ -865,6 +865,11 @@ func (s *JobsService) tagInboundMessage(ctx context.Context, e *models.JobEventN } } +// UniboxGate answers whether a workspace's plan opens the inbox. +type UniboxGate interface { + CanUseUnibox(ctx context.Context, orgID uuid.UUID) (bool, *errx.Error) +} + // notifyActionRequired tells the members who keep mailboxes running that one // received mail needing action, since nobody may be reading that mailbox. The // sender's subject stays out: this mail is phishing-shaped by selection. @@ -877,6 +882,12 @@ func (s *JobsService) notifyActionRequired(orgID uuid.UUID, mailbox string, m *m title = "Message to review in " + mailbox } notify := func(ctx context.Context) { + // An unknown answer still notifies: a missed notice costs a paying workspace more. + if s.UniboxAccess != nil { + if ok, xerr := s.UniboxAccess.CanUseUnibox(ctx, orgID); xerr == nil && !ok { + return + } + } s.Notifier.NotifyOrgAboutMessage(ctx, orgID, models.PermManageEmails|models.PermAccessUnibox, m.ID, models.NotifInboxActionRequired, title, "An incoming message was marked for review. Its claims are unverified. This is an inbox notice, not a Warmbly connection check. Review it in the inbox.", diff --git a/internal/app/consumer/service.go b/internal/app/consumer/service.go index b4248ed28..a72a40ff3 100644 --- a/internal/app/consumer/service.go +++ b/internal/app/consumer/service.go @@ -116,6 +116,9 @@ type JobsService struct { // dead-worker job moves or strands their mailboxes. Nil disables it. Notifier OrgNotifier + // UniboxAccess keeps inbox notices from workspaces whose plan locks the inbox. Nil skips the check. + UniboxAccess UniboxGate + // OpsNotifier raises instance-wide operator alerts, which are a different // audience from Notifier: the operator hears about the fleet, the tenant // hears about their mailboxes. Nil disables it. diff --git a/internal/app/email/onboarding.go b/internal/app/email/onboarding.go index 73e6b59ef..be274ddd5 100644 --- a/internal/app/email/onboarding.go +++ b/internal/app/email/onboarding.go @@ -93,7 +93,7 @@ func (s *emailService) OAuthStart(ctx context.Context, userID string, orgID *uui } // guardInboxLimit refuses a connect that would take the workspace past its -// mailbox allowance (fair use for paid plans, FreeWorkspaceMailboxLimit for +// mailbox allowance (fair use for paid plans, Subscription.FreeMailboxLimit for // free ones, unlimited without billing) and returns the resolved allowance so // the insert can enforce it again under the organization's lock. The // allowance is counted per org, so no org means it cannot be applied and the diff --git a/internal/app/feature/gate.go b/internal/app/feature/gate.go index 9dd8ef0ae..3c6d9175b 100644 --- a/internal/app/feature/gate.go +++ b/internal/app/feature/gate.go @@ -28,8 +28,8 @@ type FeatureGateService interface { // CanSendCampaignEmail checks if an organization can send campaign emails CanSendCampaignEmail(ctx context.Context, orgID uuid.UUID) (bool, *errx.Error) - // CanUseWarmup checks if an organization can use the warmup feature. - // Free-trial orgs may use warmup during their 14-day window. + // CanUseWarmup checks if an organization can use the warmup feature: + // a paid plan, or a free workspace that kept the free allowance. CanUseWarmup(ctx context.Context, orgID uuid.UUID) (bool, *errx.Error) // CanUseUnibox checks if an organization can use the unibox feature. @@ -37,7 +37,7 @@ type FeatureGateService interface { CanUseUnibox(ctx context.Context, orgID uuid.UUID) (bool, *errx.Error) // CanAddInbox returns whether the org may connect another email account. - // Free workspaces are capped at FreeWorkspaceMailboxLimit connected mailboxes. + // Free workspaces are capped at their Subscription.FreeMailboxLimit. // Paid orgs are not gated here (plan limits govern sending volume). CanAddInbox(ctx context.Context, orgID uuid.UUID, currentCount int) (bool, *errx.Error) @@ -200,7 +200,7 @@ func (s *featureGateService) CanUseUnibox(ctx context.Context, orgID uuid.UUID) return sub.CanUseUnibox(), nil } -// CanAddInbox: paid workspaces are uncapped, free ones get FreeWorkspaceMailboxLimit. +// CanAddInbox: paid workspaces are uncapped, free ones get their FreeMailboxLimit. func (s *featureGateService) CanAddInbox(ctx context.Context, orgID uuid.UUID, currentCount int) (bool, *errx.Error) { if s.selfHost { return true, nil @@ -212,7 +212,7 @@ func (s *featureGateService) CanAddInbox(ctx context.Context, orgID uuid.UUID, c if sub != nil && sub.HasPaidSubscription() { return true, nil } - return currentCount < models.FreeWorkspaceMailboxLimit, nil + return currentCount < sub.FreeMailboxLimit(), nil } // GetDailyEmailLimit returns the daily email limit for an organization diff --git a/internal/app/feature/gate_tester_test.go b/internal/app/feature/gate_tester_test.go index 12acee5c5..de1f10146 100644 --- a/internal/app/feature/gate_tester_test.go +++ b/internal/app/feature/gate_tester_test.go @@ -28,14 +28,12 @@ func TestTestPlanAccessEndsWithReviewerExpiry(t *testing.T) { "Unibox": gate.CanUseUnibox, "writing assistant": gate.CanUseWritingAssistant, "inbox agent": gate.CanUseInboxAgent, + "warmup": gate.CanUseWarmup, } { allowed, xerr := check(ctx, orgID) if xerr != nil || allowed == expired { t.Errorf("%s with expired=%v: allowed=%v, error=%v", name, expired, allowed, xerr) } } - if allowed, xerr := gate.CanUseWarmup(ctx, orgID); xerr != nil || !allowed { - t.Error("expiry must not remove normal free-pool warmup access") - } } } diff --git a/internal/app/feature/gate_warmup_plan_test.go b/internal/app/feature/gate_warmup_plan_test.go index 9ed4c57b8..6a6e9de3e 100644 --- a/internal/app/feature/gate_warmup_plan_test.go +++ b/internal/app/feature/gate_warmup_plan_test.go @@ -137,3 +137,34 @@ func TestPartnershipPlanWarmsLikeTheWarmupPlan(t *testing.T) { t.Errorf("granted Partnership plan: warmupOnly=%v product=%v, want true false", sub.IsWarmupOnly(), sub.HasProductPlan()) } } + +// A free workspace warms only if it kept the free allowance; a new one needs a plan. +func TestFreeWarmupFollowsTheKeptAllowance(t *testing.T) { + ctx := context.Background() + org := uuid.New() + must := noError(t) + + kept := &featureGateService{subRepo: stubSubs{sub: &models.Subscription{KeepsFreeWarmup: true}}} + if !must(kept.CanUseWarmup(ctx, org)) { + t.Error("a workspace that kept the free allowance must still warm") + } + if !must(kept.CanAddInbox(ctx, org, models.FreeWorkspaceMailboxLimit-1)) || must(kept.CanAddInbox(ctx, org, models.FreeWorkspaceMailboxLimit)) { + t.Errorf("a kept free workspace must hold exactly %d mailboxes", models.FreeWorkspaceMailboxLimit) + } + if must(kept.HasPremiumWarmup(ctx, org)) { + t.Error("a kept free workspace warms in the free pool, not the premium one") + } + + fresh := &featureGateService{subRepo: stubSubs{sub: &models.Subscription{}}} + if must(fresh.CanUseWarmup(ctx, org)) { + t.Error("a new free workspace must not warm without a plan") + } + if must(fresh.CanAddInbox(ctx, org, 0)) { + t.Error("a new free workspace must not connect a mailbox without a plan") + } + + none := &featureGateService{subRepo: stubSubs{}} + if must(none.CanUseWarmup(ctx, org)) || must(none.CanAddInbox(ctx, org, 0)) { + t.Error("a workspace with no subscription row must not warm or connect mailboxes") + } +} diff --git a/internal/app/instanceconfig/limits.go b/internal/app/instanceconfig/limits.go index 3f61e4386..527c27ea8 100644 --- a/internal/app/instanceconfig/limits.go +++ b/internal/app/instanceconfig/limits.go @@ -52,7 +52,7 @@ func Limits() []LimitGroup { Title: "Mailbox allowance", Entries: []LimitEntry{ {"Fair-use sends per mailbox", n(config.FairUseSendsPerMailbox), "sends/day", "A paid plan holds one mailbox for every this many daily sends it includes; a plan with no daily cap holds unlimited mailboxes."}, - {"Free workspace mailboxes", n(models.FreeWorkspaceMailboxLimit), "per organization", "Without a paid plan."}, + {"Free workspace mailboxes", n(models.FreeWorkspaceMailboxLimit), "per organization", "Only workspaces that kept the free plan; new ones need a paid plan."}, {"Bulk connect batch", n(config.MailboxBulkBatchMax), "rows/request", "The most SMTP/IMAP rows one bulk connect call carries; the dashboard streams a CSV through batches of this size."}, {"Bulk connect concurrency", n(config.MailboxBulkConcurrency), "validations", "Credentials dialled at the same time within one batch."}, }, diff --git a/internal/app/organization/service.go b/internal/app/organization/service.go index d9e0e41fa..d17b43395 100644 --- a/internal/app/organization/service.go +++ b/internal/app/organization/service.go @@ -1280,7 +1280,7 @@ func (s *organizationService) CanAddCampaign(ctx context.Context, orgID uuid.UUI // // 1. no billing provider: unlimited // 2. an operator override: the override -// 3. no paid subscription: FreeWorkspaceMailboxLimit +// 3. no paid subscription: Subscription.FreeMailboxLimit (none for new workspaces) // 4. the plan's explicit mailbox column, when it carries one // 5. the plan's daily sends divided by FairUseSendsPerMailbox // 6. a plan with no daily send cap: unlimited @@ -1336,7 +1336,7 @@ func (s *organizationService) MailboxAllowance(ctx context.Context, orgID uuid.U case override != nil && override.MaxEmailAccounts > 0: set(override.MaxEmailAccounts, models.MailboxAllowanceOverride) case !a.Paid: - set(models.FreeWorkspaceMailboxLimit, models.MailboxAllowanceFree) + set(sub.FreeMailboxLimit(), models.MailboxAllowanceFree) case sub.Plan != nil && sub.Plan.MaxEmailAccounts != nil && *sub.Plan.MaxEmailAccounts > 0: set(*sub.Plan.MaxEmailAccounts, models.MailboxAllowancePlan) case a.PlanDailySends != nil: diff --git a/internal/errx/common.go b/internal/errx/common.go index 51c29a7b2..71d36e479 100644 --- a/internal/errx/common.go +++ b/internal/errx/common.go @@ -319,6 +319,10 @@ var ( // workspace holds its whole allowance. The identifier is stable so the // dashboard can open the request-more flow instead of showing the text. func MailboxAllowanceReached(used, allowance int, paid bool) *Error { + if !paid && allowance == 0 { + return NewWithIdentifier(Forbidden, "mailbox_allowance_reached", + "Connecting and warming mailboxes needs a plan. Choose one to add a mailbox.") + } if !paid { return NewWithIdentifier(Forbidden, "mailbox_allowance_reached", fmt.Sprintf("A free workspace holds up to %d mailboxes. Choose a plan to add more.", allowance)) diff --git a/internal/infrastructure/db/migrations/000352_subscription_free_warmup.down.sql b/internal/infrastructure/db/migrations/000352_subscription_free_warmup.down.sql new file mode 100644 index 000000000..872504897 --- /dev/null +++ b/internal/infrastructure/db/migrations/000352_subscription_free_warmup.down.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE subscriptions DROP COLUMN keeps_free_warmup; +COMMIT; diff --git a/internal/infrastructure/db/migrations/000352_subscription_free_warmup.up.sql b/internal/infrastructure/db/migrations/000352_subscription_free_warmup.up.sql new file mode 100644 index 000000000..a3e0d4820 --- /dev/null +++ b/internal/infrastructure/db/migrations/000352_subscription_free_warmup.up.sql @@ -0,0 +1,5 @@ +BEGIN; +-- Every workspace that exists now keeps the free warmup allowance; new ones start without it. +ALTER TABLE subscriptions ADD COLUMN keeps_free_warmup boolean NOT NULL DEFAULT true; +ALTER TABLE subscriptions ALTER COLUMN keeps_free_warmup SET DEFAULT false; +COMMIT; diff --git a/internal/models/subscriptions.go b/internal/models/subscriptions.go index 8941d04e5..ebaef1f13 100644 --- a/internal/models/subscriptions.go +++ b/internal/models/subscriptions.go @@ -169,6 +169,9 @@ type Subscription struct { // Enterprise flag IsEnterprise bool `json:"is_enterprise"` + // KeepsFreeWarmup marks a workspace that had the free warmup allowance before it was withdrawn from new ones. + KeepsFreeWarmup bool `json:"keeps_free_warmup"` + // Joined data Plan *Plan `json:"plan,omitempty"` @@ -276,10 +279,18 @@ func (s *Subscription) CanSendEmails() bool { return false } -// CanUseWarmup: every workspace may warm its mailboxes (free ones in the free -// pool, up to FreeWorkspaceMailboxLimit connected mailboxes). +// CanUseWarmup: a paid plan, or a workspace that kept the free allowance +// (the free pool, up to FreeWorkspaceMailboxLimit connected mailboxes). func (s *Subscription) CanUseWarmup() bool { - return true + return s.HasPaidSubscription() || s.KeepsFreeWarmup +} + +// FreeMailboxLimit is the mailboxes an unsubscribed workspace may hold: none unless it kept the free allowance. +func (s *Subscription) FreeMailboxLimit() int { + if s != nil && s.KeepsFreeWarmup { + return FreeWorkspaceMailboxLimit + } + return 0 } // CanUseUnibox returns true if user can use unibox feature. diff --git a/internal/repository/pg_subscription.go b/internal/repository/pg_subscription.go index 0faa29b7f..849989d0c 100644 --- a/internal/repository/pg_subscription.go +++ b/internal/repository/pg_subscription.go @@ -17,7 +17,7 @@ import ( // order. With `SELECT *`, the trailing NULL free-trial timestamps land in the // non-nullable created_at/updated_at scan slots and pgx fails with // "cannot scan NULL into *time.Time", 500-ing every subscription read. -const subscriptionColumns = `id, user_id, organization_id, plan_id, stripe_customer_id, stripe_subscription_id, stripe_price_id, status, current_period_start, current_period_end, cancel_at_period_end, canceled_at, trial_start, trial_end, free_trial_started_at, free_trial_ends_at, is_enterprise, created_at, updated_at, managed_at, managed_by, managed_reason, managed_until, managed_plan_id` +const subscriptionColumns = `id, user_id, organization_id, plan_id, stripe_customer_id, stripe_subscription_id, stripe_price_id, status, current_period_start, current_period_end, cancel_at_period_end, canceled_at, trial_start, trial_end, free_trial_started_at, free_trial_ends_at, is_enterprise, created_at, updated_at, managed_at, managed_by, managed_reason, managed_until, managed_plan_id, keeps_free_warmup` type SubscriptionRepository interface { Create(ctx context.Context, sub *models.Subscription) error @@ -139,6 +139,7 @@ func (r *subscriptionRepository) scanSubscription(ctx context.Context, query str &sub.FreeTrialStartedAt, &sub.FreeTrialEndsAt, &sub.IsEnterprise, &sub.CreatedAt, &sub.UpdatedAt, &sub.ManagedAt, &sub.ManagedBy, &sub.ManagedReason, &sub.ManagedUntil, &sub.ManagedPlanID, + &sub.KeepsFreeWarmup, ) if err == pgx.ErrNoRows { return nil, nil diff --git a/site/src/components/CTA.astro b/site/src/components/CTA.astro index c42e6655c..384a3eb29 100644 --- a/site/src/components/CTA.astro +++ b/site/src/components/CTA.astro @@ -17,8 +17,8 @@ interface Props { } const { title = 'Start sending cold email that lands.', - description = 'Connect a mailbox and start warming it today. Free to start, free to self-host.', - primaryLabel = 'Start free', + description = 'Pick a plan, connect your mailboxes and start warming them today. Unlimited mailboxes and warmup on every paid plan.', + primaryLabel = 'Get started', primaryHref = 'https://app.warmbly.com/auth/register', secondaryLabel = 'See pricing', secondaryHref = '/pricing/', diff --git a/site/src/components/FeatureGrid.astro b/site/src/components/FeatureGrid.astro index 7392c5205..a27d5c174 100644 --- a/site/src/components/FeatureGrid.astro +++ b/site/src/components/FeatureGrid.astro @@ -48,7 +48,7 @@ const body = 'mt-2 max-w-xl text-[16px] md:text-[17px] leading-[1.55] text-slate

Open source

-

Use Warmbly Cloud, or install it on your own server with one command.

+

Use Warmbly Cloud and its shared warmup pool, or install it on your own server with one command, where warmup only pairs your own mailboxes.

diff --git a/site/src/components/Header.astro b/site/src/components/Header.astro index e95ec6e77..8facb2266 100644 --- a/site/src/components/Header.astro +++ b/site/src/components/Header.astro @@ -230,7 +230,7 @@ function active(match?: string) { (onSky ? '' : 'bg-slate-900 text-white hover:bg-slate-800') } > - Start free + Get started