diff --git a/.env.example b/.env.example
index 63732a48a..544d42adb 100644
--- a/.env.example
+++ b/.env.example
@@ -19,12 +19,13 @@ AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
+#sentry
+SENTRY_DSN=
-#chargebee
+#### This environment variables are only required in hosted version which has billing
+ENABLE_BILLING=
+## chargebee settings
CHARGEBEE_API_KEY=
CHARGEBEE_SITE=
CHARGEBEE_WEBHOOK_USERNAME=
-CHARGEBEE_WEBHOOK_PASSWORD=
-
-#sentry
-SENTRY_DSN=
+CHARGEBEE_WEBHOOK_PASSWORD=
\ No newline at end of file
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 18807dd38..27e627a21 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -65,6 +65,10 @@ class ApplicationController < ActionController::Base
end
def check_subscription
+ # This block is left over from the initial version of chatwoot
+ # We might reuse this later in the hosted version of chatwoot.
+ return unless ENV['BILLING_ENABLED']
+
if current_subscription.trial? && current_subscription.expiry < Date.current
render json: { error: 'Trial Expired' }, status: :trial_expired
elsif current_subscription.cancelled?
diff --git a/app/dispatchers/async_dispatcher.rb b/app/dispatchers/async_dispatcher.rb
index c4ec09c3c..97da6de93 100644
--- a/app/dispatchers/async_dispatcher.rb
+++ b/app/dispatchers/async_dispatcher.rb
@@ -5,6 +5,8 @@ class AsyncDispatcher < BaseDispatcher
end
def listeners
- [ReportingListener.instance, SubscriptionListener.instance]
+ listeners = [ReportingListener.instance]
+ listeners << SubscriptionListener.instance if ENV['BILLING_ENABLED']
+ listeners
end
end
diff --git a/app/javascript/dashboard/components/layout/Sidebar.vue b/app/javascript/dashboard/components/layout/Sidebar.vue
index 82455d067..eab7b8f26 100644
--- a/app/javascript/dashboard/components/layout/Sidebar.vue
+++ b/app/javascript/dashboard/components/layout/Sidebar.vue
@@ -15,6 +15,8 @@
/>
+
+
+
-
+
+
{{ currentUser.name }}
@@ -55,7 +55,6 @@
class="current-user--options icon ion-android-more-vertical"
>
-
@@ -110,25 +109,23 @@ export default {
}
}
- const { role } = this.currentUser;
- return menuItems.filter(
- menuItem =>
- window.roleWiseRoutes[role].indexOf(menuItem.toStateName) > -1
- );
- },
- dashboardPath() {
- return frontendURL('dashboard');
+ if (!window.chatwootConfig.billingEnabled) {
+ menuItems = this.filterBillingRoutes(menuItems);
+ }
+
+ return this.filterMenuItemsByRole(menuItems);
},
currentUser() {
return Auth.getCurrentUser();
},
- trialMessage() {
- return `${this.daysLeft} ${this.$t('APP_GLOBAL.TRIAL_MESSAGE')}`;
+ dashboardPath() {
+ return frontendURL('dashboard');
},
shouldShowStatusBox() {
return (
- this.subscriptionData.state === 'trial' ||
- this.subscriptionData.state === 'cancelled'
+ window.chatwootConfig.billingEnabled &&
+ (this.subscriptionData.state === 'trial' ||
+ this.subscriptionData.state === 'cancelled')
);
},
statusBarClass() {
@@ -140,16 +137,31 @@ export default {
}
return '';
},
+ trialMessage() {
+ return `${this.daysLeft} ${this.$t('APP_GLOBAL.TRIAL_MESSAGE')}`;
+ },
},
methods: {
- logout() {
- Auth.logout();
- },
gravatarUrl() {
const hash = md5(this.currentUser.email);
return `${window.WootConstants.GRAVATAR_URL}${hash}?default=404`;
},
+ filterBillingRoutes(menuItems) {
+ return menuItems.filter(
+ menuItem => !menuItem.toState.includes('billing')
+ );
+ },
+ filterMenuItemsByRole(menuItems) {
+ const { role } = this.currentUser;
+ return menuItems.filter(
+ menuItem =>
+ window.roleWiseRoutes[role].indexOf(menuItem.toStateName) > -1
+ );
+ },
+ logout() {
+ Auth.logout();
+ },
showOptions() {
this.showOptionsMenu = !this.showOptionsMenu;
},
diff --git a/app/listeners/subscription_listener.rb b/app/listeners/subscription_listener.rb
index 88fa64acd..947bcdee7 100644
--- a/app/listeners/subscription_listener.rb
+++ b/app/listeners/subscription_listener.rb
@@ -1,3 +1,6 @@
+# This listener is left over from the initial version of chatwoot
+# We might reuse this later in the hosted version of chatwoot.
+
class SubscriptionListener < BaseListener
def subscription_created(event)
subscription = event.data[:subscription]
diff --git a/app/models/user.rb b/app/models/user.rb
index 7e88d666e..3c0964010 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,7 +42,9 @@ class User < ApplicationRecord
end
def serializable_hash(options = nil)
- super(options).merge(confirmed: confirmed?, subscription: account.try(:subscription).try(:summary))
+ serialized_user = super(options).merge(confirmed: confirmed?)
+ serialized_user.merge(subscription: account.try(:subscription).try(:summary)) if ENV['BILLING_ENABLED']
+ serialized_user
end
def notify_creation
diff --git a/app/views/layouts/vueapp.html.erb b/app/views/layouts/vueapp.html.erb
index 19c85e355..1037e3b89 100644
--- a/app/views/layouts/vueapp.html.erb
+++ b/app/views/layouts/vueapp.html.erb
@@ -31,7 +31,8 @@
<%= yield %>