Open platform to collect and prioritize feedback
Pro features for legacy pro accounts.
Matt Roberts682f0403123a
diff --git a/app/services/sqlstore/dbEntities/tenant.go b/app/services/sqlstore/dbEntities/tenant.goindex 6c1f206ad..dad5671d7 100644--- a/app/services/sqlstore/dbEntities/tenant.go+++ b/app/services/sqlstore/dbEntities/tenant.go@@ -8,24 +8,25 @@ import ()type Tenant struct {- ID int `db:"id"`- Name string `db:"name"`- Subdomain string `db:"subdomain"`- CNAME string `db:"cname"`- Invitation string `db:"invitation"`- WelcomeMessage string `db:"welcome_message"`- WelcomeHeader string `db:"welcome_header"`- Status int `db:"status"`- Locale string `db:"locale"`- IsPrivate bool `db:"is_private"`- LogoBlobKey string `db:"logo_bkey"`- CustomCSS string `db:"custom_css"`- AllowedSchemes string `db:"allowed_schemes"`- IsEmailAuthAllowed bool `db:"is_email_auth_allowed"`- IsFeedEnabled bool `db:"is_feed_enabled"`- PreventIndexing bool `db:"prevent_indexing"`- IsModerationEnabled bool `db:"is_moderation_enabled"`- IsPro bool `db:"is_pro"`+ ID int `db:"id"`+ Name string `db:"name"`+ Subdomain string `db:"subdomain"`+ CNAME string `db:"cname"`+ Invitation string `db:"invitation"`+ WelcomeMessage string `db:"welcome_message"`+ WelcomeHeader string `db:"welcome_header"`+ Status int `db:"status"`+ Locale string `db:"locale"`+ IsPrivate bool `db:"is_private"`+ LogoBlobKey string `db:"logo_bkey"`+ CustomCSS string `db:"custom_css"`+ AllowedSchemes string `db:"allowed_schemes"`+ IsEmailAuthAllowed bool `db:"is_email_auth_allowed"`+ IsFeedEnabled bool `db:"is_feed_enabled"`+ PreventIndexing bool `db:"prevent_indexing"`+ IsModerationEnabled bool `db:"is_moderation_enabled"`+ IsPro bool `db:"is_pro"`+ HasPaddleSubscription bool `db:"has_paddle_subscription"`}func (t *Tenant) ToModel() *entity.Tenant {@@ -39,8 +40,8 @@ func (t *Tenant) ToModel() *entity.Tenant {// Self-hosted: check if license service validated successfullyhasCommercialFeatures = services.IsCommercialFeatureEnabled(services.FeatureContentModeration)} else {- // Hosted multi-tenant: check if this tenant has Pro subscription- hasCommercialFeatures = t.IsPro+ // Hosted multi-tenant: check if this tenant has Pro subscription or legacy Paddle subscription+ hasCommercialFeatures = t.IsPro || t.HasPaddleSubscription}tenant := &entity.Tenant{diff --git a/app/services/sqlstore/postgres/billing.go b/app/services/sqlstore/postgres/billing.goindex 0922f6a07..999ad1a99 100644--- a/app/services/sqlstore/postgres/billing.go+++ b/app/services/sqlstore/postgres/billing.go@@ -76,7 +76,7 @@ func activateStripeSubscription(ctx context.Context, c *cmd.ActivateStripeSubscrINSERT INTO tenants_billing (tenant_id, stripe_customer_id, stripe_subscription_id, license_key)VALUES ($1, $2, $3, $4)ON CONFLICT (tenant_id) DO UPDATE- SET stripe_customer_id = $2, stripe_subscription_id = $3, license_key = $4+ SET stripe_customer_id = $2, stripe_subscription_id = $3, license_key = $4, paddle_subscription_id = NULL`, c.TenantID, c.CustomerID, c.SubscriptionID, c.LicenseKey)if err != nil {return errors.Wrap(err, "failed to activate stripe subscription")diff --git a/app/services/sqlstore/postgres/tenant.go b/app/services/sqlstore/postgres/tenant.goindex 03e9a4638..657c83a23 100644--- a/app/services/sqlstore/postgres/tenant.go+++ b/app/services/sqlstore/postgres/tenant.go@@ -208,9 +208,11 @@ func getFirstTenant(ctx context.Context, q *query.GetFirstTenant) error {tenant := dbEntities.Tenant{}err := trx.Get(&tenant, `- SELECT id, name, subdomain, cname, invitation, locale, welcome_message, welcome_header, status, is_private, logo_bkey, custom_css, allowed_schemes, is_email_auth_allowed, is_feed_enabled, is_moderation_enabled, prevent_indexing, is_pro- FROM tenants- ORDER BY id LIMIT 1+ SELECT t.id, t.name, t.subdomain, t.cname, t.invitation, t.locale, t.welcome_message, t.welcome_header, t.status, t.is_private, t.logo_bkey, t.custom_css, t.allowed_schemes, t.is_email_auth_allowed, t.is_feed_enabled, t.is_moderation_enabled, t.prevent_indexing, t.is_pro,+ (b.paddle_subscription_id IS NOT NULL AND b.stripe_subscription_id IS NULL) AS has_paddle_subscription+ FROM tenants t+ LEFT JOIN tenants_billing b ON b.tenant_id = t.id+ ORDER BY t.id LIMIT 1`)if err != nil {return errors.Wrap(err, "failed to get first tenant")@@ -226,10 +228,12 @@ func getTenantByDomain(ctx context.Context, q *query.GetTenantByDomain) error {tenant := dbEntities.Tenant{}err := trx.Get(&tenant, `- SELECT id, name, subdomain, cname, invitation, locale, welcome_message, welcome_header, status, is_private, logo_bkey, custom_css, allowed_schemes, is_email_auth_allowed, is_feed_enabled, is_moderation_enabled, prevent_indexing, is_pro+ SELECT t.id, t.name, t.subdomain, t.cname, t.invitation, t.locale, t.welcome_message, t.welcome_header, t.status, t.is_private, t.logo_bkey, t.custom_css, t.allowed_schemes, t.is_email_auth_allowed, t.is_feed_enabled, t.is_moderation_enabled, t.prevent_indexing, t.is_pro,+ (b.paddle_subscription_id IS NOT NULL AND b.stripe_subscription_id IS NULL) AS has_paddle_subscriptionFROM tenants t- WHERE subdomain = $1 OR subdomain = $2 OR cname = $3- ORDER BY cname DESC+ LEFT JOIN tenants_billing b ON b.tenant_id = t.id+ WHERE t.subdomain = $1 OR t.subdomain = $2 OR t.cname = $3+ ORDER BY t.cname DESC`, env.Subdomain(q.Domain), q.Domain, q.Domain)if err != nil {return errors.Wrap(err, "failed to get tenant with domain '%s'", q.Domain)