Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Renamed variables. Fixed issue with not showing the "legacy" billing message

Matt Roberts1789538aaa94
diff --git a/app/handlers/admin.go b/app/handlers/admin.go
index e42f420ef..e21d3724a 100644
--- a/app/handlers/admin.go
+++ b/app/handlers/admin.go
@@ -36,10 +36,10 @@ func AdvancedSettingsPage() web.HandlerFunc {
Page: "Administration/pages/AdvancedSettings.page",
Title: "Advanced · Site Settings",
Data: web.Map{
- "customCSS": c.Tenant().CustomCSS,
- "allowedSchemes": c.Tenant().AllowedSchemes,
- "licenseKey": billingState.Result.LicenseKey,
- "isCommercial": c.Tenant().IsCommercial,
+ "customCSS": c.Tenant().CustomCSS,
+ "allowedSchemes": c.Tenant().AllowedSchemes,
+ "licenseKey": billingState.Result.LicenseKey,
+ "hasCommercialFeatures": c.Tenant().HasCommercialFeatures,
},
})
}
diff --git a/app/handlers/billing.go b/app/handlers/billing.go
index 517d8bea1..ec6cd21ac 100644
--- a/app/handlers/billing.go
+++ b/app/handlers/billing.go
@@ -27,9 +27,9 @@ func ManageBilling() web.HandlerFunc {
Data: web.Map{
"stripeCustomerID": billingState.Result.CustomerID,
"stripeSubscriptionID": billingState.Result.SubscriptionID,
- "licenseKey": billingState.Result.LicenseKey,
- "paddleSubscriptionID": billingState.Result.PaddleSubscriptionID,
- "isCommercial": c.Tenant().IsCommercial,
+ "licenseKey": billingState.Result.LicenseKey,
+ "paddleSubscriptionID": billingState.Result.PaddleSubscriptionID,
+ "hasCommercialFeatures": c.Tenant().HasCommercialFeatures,
},
})
}
diff --git a/app/models/entity/tenant.go b/app/models/entity/tenant.go
index b1f257943..064714600 100644
--- a/app/models/entity/tenant.go
+++ b/app/models/entity/tenant.go
@@ -22,8 +22,8 @@ type Tenant struct {
IsEmailAuthAllowed bool `json:"isEmailAuthAllowed"`
IsFeedEnabled bool `json:"isFeedEnabled"`
PreventIndexing bool `json:"preventIndexing"`
- IsModerationEnabled bool `json:"isModerationEnabled"`
- IsCommercial bool `json:"isCommercial"`
+ IsModerationEnabled bool `json:"isModerationEnabled"`
+ HasCommercialFeatures bool `json:"hasCommercialFeatures"`
}
func (t *Tenant) IsDisabled() bool {
diff --git a/app/pkg/web/testdata/home_ssr.html b/app/pkg/web/testdata/home_ssr.html
index 95c7c580b..7d072bc97 100755
--- a/app/pkg/web/testdata/home_ssr.html
+++ b/app/pkg/web/testdata/home_ssr.html
@@ -45,7 +45,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"","subdomain":"","invitation":"","welcomeMessage":"","welcomeHeader":"","cname":"","status":0,"locale":"en","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false,"isModerationEnabled":false,"isCommercial":false},"title":"My Page Title · "}
+ {"contextID":"CONTEXT_ID","description":"My Page Description","page":"Test.page","props":{"countPerStatus":{},"posts":[],"tags":[]},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"","subdomain":"","invitation":"","welcomeMessage":"","welcomeHeader":"","cname":"","status":0,"locale":"en","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false,"isModerationEnabled":false,"hasCommercialFeatures":false},"title":"My Page Title · "}
</script>
diff --git a/app/pkg/web/testdata/tenant.html b/app/pkg/web/testdata/tenant.html
index c77a1024a..d8862b06a 100755
--- a/app/pkg/web/testdata/tenant.html
+++ b/app/pkg/web/testdata/tenant.html
@@ -45,7 +45,7 @@
<script id="server-data" type="application/json">
- {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","welcomeHeader":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false,"isModerationEnabled":false,"isCommercial":false},"title":"Game of Thrones"}
+ {"contextID":"CONTEXT_ID","page":"","props":{},"sessionID":"","settings":{"allowAllowedSchemes":true,"assetsURL":"https://demo.test.fider.io:3000","baseURL":"https://demo.test.fider.io:3000","domain":".test.fider.io","environment":"test","googleAnalytics":"","hasLegal":true,"isBillingEnabled":false,"locale":"en","localeDirection":"ltr","mode":"multi","oauth":[],"postWithTags":true},"tenant":{"id":0,"name":"Game of Thrones","subdomain":"","invitation":"","welcomeMessage":"","welcomeHeader":"","cname":"","status":0,"locale":"","isPrivate":false,"logoBlobKey":"","allowedSchemes":"","isEmailAuthAllowed":false,"isFeedEnabled":false,"preventIndexing":false,"isModerationEnabled":false,"hasCommercialFeatures":false},"title":"Game of Thrones"}
</script>
diff --git a/app/services/sqlstore/dbEntities/tenant.go b/app/services/sqlstore/dbEntities/tenant.go
index 59daf6b23..6c1f206ad 100644
--- a/app/services/sqlstore/dbEntities/tenant.go
+++ b/app/services/sqlstore/dbEntities/tenant.go
@@ -33,35 +33,35 @@ func (t *Tenant) ToModel() *entity.Tenant {
return nil
}
- // Compute isCommercial based on hosting mode
- var isCommercial bool
+ // Compute hasCommercialFeatures based on hosting mode
+ var hasCommercialFeatures bool
if env.IsSingleHostMode() {
// Self-hosted: check if license service validated successfully
- isCommercial = services.IsCommercialFeatureEnabled(services.FeatureContentModeration)
+ hasCommercialFeatures = services.IsCommercialFeatureEnabled(services.FeatureContentModeration)
} else {
// Hosted multi-tenant: check if this tenant has Pro subscription
- isCommercial = t.IsPro
+ hasCommercialFeatures = t.IsPro
}
tenant := &entity.Tenant{
- ID: t.ID,
- Name: t.Name,
- Subdomain: t.Subdomain,
- CNAME: t.CNAME,
- Invitation: t.Invitation,
- WelcomeMessage: t.WelcomeMessage,
- WelcomeHeader: t.WelcomeHeader,
- Status: enum.TenantStatus(t.Status),
- Locale: t.Locale,
- IsPrivate: t.IsPrivate,
- LogoBlobKey: t.LogoBlobKey,
- CustomCSS: t.CustomCSS,
- AllowedSchemes: t.AllowedSchemes,
- IsEmailAuthAllowed: t.IsEmailAuthAllowed,
- IsFeedEnabled: t.IsFeedEnabled,
- PreventIndexing: t.PreventIndexing,
- IsModerationEnabled: t.IsModerationEnabled,
- IsCommercial: isCommercial,
+ ID: t.ID,
+ Name: t.Name,
+ Subdomain: t.Subdomain,
+ CNAME: t.CNAME,
+ Invitation: t.Invitation,
+ WelcomeMessage: t.WelcomeMessage,
+ WelcomeHeader: t.WelcomeHeader,
+ Status: enum.TenantStatus(t.Status),
+ Locale: t.Locale,
+ IsPrivate: t.IsPrivate,
+ LogoBlobKey: t.LogoBlobKey,
+ CustomCSS: t.CustomCSS,
+ AllowedSchemes: t.AllowedSchemes,
+ IsEmailAuthAllowed: t.IsEmailAuthAllowed,
+ IsFeedEnabled: t.IsFeedEnabled,
+ PreventIndexing: t.PreventIndexing,
+ IsModerationEnabled: t.IsModerationEnabled,
+ HasCommercialFeatures: hasCommercialFeatures,
}
return tenant
diff --git a/app/tasks/userlist.go b/app/tasks/userlist.go
index 4709330b8..c3bf9aa9d 100644
--- a/app/tasks/userlist.go
+++ b/app/tasks/userlist.go
@@ -20,7 +20,7 @@ func UserListCreateCompany(tenant entity.Tenant, user entity.User) worker.Task {
})
plan := enum.PlanFree
- if tenant.IsCommercial {
+ if tenant.HasCommercialFeatures {
plan = enum.PlanPro
}
diff --git a/commercial/components/ModerationIndicator.tsx b/commercial/components/ModerationIndicator.tsx
index 0d6275fee..000d574ad 100644
--- a/commercial/components/ModerationIndicator.tsx
+++ b/commercial/components/ModerationIndicator.tsx
@@ -11,7 +11,7 @@ export const ModerationIndicator = () => {
const [loading, setLoading] = useState(true)
// Check if commercial license is available
- const hasCommercialLicense = fider.session.tenant.isCommercial
+ const hasCommercialLicense = fider.session.tenant.hasCommercialFeatures
useEffect(() => {
const fetchCount = async () => {
diff --git a/commercial/init.go b/commercial/init.go
index 8572f3b9d..6380a8908 100644
--- a/commercial/init.go
+++ b/commercial/init.go
@@ -83,7 +83,7 @@ func (s *commercialLicenseService) IsCommercialFeatureEnabled(feature string) bo
}
// In multi-tenant mode, this is a global check
- // Per-tenant checking happens via tenant.IsCommercial()
+ // Per-tenant checking happens via tenant.HasCommercialFeatures
return true
}
diff --git a/public/models/identity.ts b/public/models/identity.ts
index 9454c5564..582e1895e 100644
--- a/public/models/identity.ts
+++ b/public/models/identity.ts
@@ -14,7 +14,7 @@ export interface Tenant {
isEmailAuthAllowed: boolean
isFeedEnabled: boolean
isModerationEnabled: boolean
- isCommercial: boolean
+ hasCommercialFeatures: boolean
}
export enum TenantStatus {
diff --git a/public/pages/Administration/pages/AdvancedSettings.page.tsx b/public/pages/Administration/pages/AdvancedSettings.page.tsx
index e95efca68..b0050502a 100644
--- a/public/pages/Administration/pages/AdvancedSettings.page.tsx
+++ b/public/pages/Administration/pages/AdvancedSettings.page.tsx
@@ -8,7 +8,7 @@ interface AdvancedSettingsPageProps {
customCSS: string
allowedSchemes: string
licenseKey: string
- isCommercial: boolean
+ hasCommercialFeatures: boolean
}
interface AdvancedSettingsPageState {
@@ -60,7 +60,7 @@ export default class AdvancedSettingsPage extends AdminBasePage<AdvancedSettings
public content() {
return (
<Form error={this.state.error}>
- {this.props.isCommercial && this.props.licenseKey && (
+ {this.props.hasCommercialFeatures && this.props.licenseKey && (
<div className="field">
<label>Commercial License Key</label>
<p className="text-muted">Use this key to run Fider self-hosted with commercial features (content moderation).</p>
diff --git a/public/pages/Administration/pages/ManageBilling.page.tsx b/public/pages/Administration/pages/ManageBilling.page.tsx
index 2fc2ab9ee..2f83c3b76 100644
--- a/public/pages/Administration/pages/ManageBilling.page.tsx
+++ b/public/pages/Administration/pages/ManageBilling.page.tsx
@@ -13,7 +13,7 @@ interface ManageBillingPageProps {
stripeSubscriptionID: string
licenseKey: string
paddleSubscriptionID: string
- isCommercial: boolean
+ hasCommercialFeatures: boolean
}
interface PlanCardProps {
@@ -104,10 +104,10 @@ const ManageBillingPage = (props: ManageBillingPageProps) => {
const [isLoading, setIsLoading] = useState(false)
// Detect Paddle customers who need to migrate
- const isPaddleCustomer = Boolean(props.paddleSubscriptionID && !props.stripeSubscriptionID && props.isCommercial)
+ const isPaddleCustomer = Boolean(props.paddleSubscriptionID && !props.stripeSubscriptionID)
// Display as commercial only if they're truly a Stripe customer
- const displayAsCommercial = props.isCommercial && !isPaddleCustomer
+ const displayAsCommercial = props.hasCommercialFeatures && !isPaddleCustomer
const openPortal = async () => {
setIsLoading(true)
diff --git a/public/pages/Administration/pages/PrivacySettings.page.tsx b/public/pages/Administration/pages/PrivacySettings.page.tsx
index 6ccb46a6e..0dc561ffa 100644
--- a/public/pages/Administration/pages/PrivacySettings.page.tsx
+++ b/public/pages/Administration/pages/PrivacySettings.page.tsx
@@ -71,7 +71,7 @@ export default class PrivacySettingsPage extends AdminBasePage<any, PrivacySetti
</p>
</Field>
{/* Moderation requires commercial plan */}
- {Fider.session.tenant.isCommercial && (
+ {Fider.session.tenant.hasCommercialFeatures && (
<Field label="Content Moderation">
<Toggle disabled={!Fider.session.user.isAdministrator} active={this.state.isModerationEnabled} onToggle={this.moderationToggle} />
<p className="text-muted mt-1">
diff --git a/public/services/fider.ts b/public/services/fider.ts
index 9c679569e..6395361e0 100644
--- a/public/services/fider.ts
+++ b/public/services/fider.ts
@@ -42,11 +42,13 @@ export class FiderSession {
}
public get isModerationRequiredForNewPost(): boolean {
- return this.pTenant.isCommercial && this.pTenant.isModerationEnabled && this.isAuthenticated && this.pUser!.role === "visitor" && !this.pUser!.isTrusted
+ return (
+ this.pTenant.hasCommercialFeatures && this.pTenant.isModerationEnabled && this.isAuthenticated && this.pUser!.role === "visitor" && !this.pUser!.isTrusted
+ )
}
public get showModerationControls(): boolean {
- return this.pTenant.isCommercial && this.pTenant.isModerationEnabled && this.isAuthenticated && (this.pUser?.isCollaborator ?? false)
+ return this.pTenant.hasCommercialFeatures && this.pTenant.isModerationEnabled && this.isAuthenticated && (this.pUser?.isCollaborator ?? false)
}
}