mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
chore: Add ee helper, custom_attributes to account (#5058)
This commit is contained in:
@@ -195,3 +195,7 @@ USE_INBOX_AVATAR_FOR_BOT=true
|
|||||||
# If you want to use official mobile app,
|
# If you want to use official mobile app,
|
||||||
# the notifications would be relayed via a Chatwoot server
|
# the notifications would be relayed via a Chatwoot server
|
||||||
ENABLE_PUSH_RELAY_SERVER=true
|
ENABLE_PUSH_RELAY_SERVER=true
|
||||||
|
|
||||||
|
# Stripe API key
|
||||||
|
STRIPE_SECRET_KEY=
|
||||||
|
STRIPE_WEBHOOK_SECRET=
|
||||||
|
|||||||
3
Gemfile
3
Gemfile
@@ -127,6 +127,9 @@ gem 'working_hours'
|
|||||||
# full text search for articles
|
# full text search for articles
|
||||||
gem 'pg_search'
|
gem 'pg_search'
|
||||||
|
|
||||||
|
# Subscriptions, Billing
|
||||||
|
gem 'stripe'
|
||||||
|
|
||||||
group :production, :staging do
|
group :production, :staging do
|
||||||
# we dont want request timing out in development while using byebug
|
# we dont want request timing out in development while using byebug
|
||||||
gem 'rack-timeout'
|
gem 'rack-timeout'
|
||||||
|
|||||||
@@ -616,6 +616,7 @@ GEM
|
|||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
squasher (0.6.2)
|
squasher (0.6.2)
|
||||||
statsd-ruby (1.5.0)
|
statsd-ruby (1.5.0)
|
||||||
|
stripe (6.5.0)
|
||||||
telephone_number (1.4.16)
|
telephone_number (1.4.16)
|
||||||
thor (1.2.1)
|
thor (1.2.1)
|
||||||
tilt (2.0.10)
|
tilt (2.0.10)
|
||||||
@@ -769,6 +770,7 @@ DEPENDENCIES
|
|||||||
spring
|
spring
|
||||||
spring-watcher-listen
|
spring-watcher-listen
|
||||||
squasher
|
squasher
|
||||||
|
stripe
|
||||||
telephone_number
|
telephone_number
|
||||||
time_diff
|
time_diff
|
||||||
twilio-ruby (~> 5.66)
|
twilio-ruby (~> 5.66)
|
||||||
@@ -787,4 +789,4 @@ RUBY VERSION
|
|||||||
ruby 3.0.4p208
|
ruby 3.0.4p208
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.3.16
|
2.3.14
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ class ApiClient {
|
|||||||
|
|
||||||
baseUrl() {
|
baseUrl() {
|
||||||
let url = this.apiVersion;
|
let url = this.apiVersion;
|
||||||
|
|
||||||
|
if (this.options.enterprise) {
|
||||||
|
url = `/enterprise${url}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.options.accountScoped) {
|
if (this.options.accountScoped) {
|
||||||
const isInsideAccountScopedURLs = window.location.pathname.includes(
|
const isInsideAccountScopedURLs = window.location.pathname.includes(
|
||||||
'/app/accounts'
|
'/app/accounts'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import InboxesAPI from '../../api/inboxes';
|
|||||||
import WebChannel from '../../api/channel/webChannel';
|
import WebChannel from '../../api/channel/webChannel';
|
||||||
import FBChannel from '../../api/channel/fbChannel';
|
import FBChannel from '../../api/channel/fbChannel';
|
||||||
import TwilioChannel from '../../api/channel/twilioChannel';
|
import TwilioChannel from '../../api/channel/twilioChannel';
|
||||||
import { parseAPIErrorResponse } from '../utils/api';
|
import { throwErrorMessage } from '../utils/api';
|
||||||
|
|
||||||
const buildInboxData = inboxParams => {
|
const buildInboxData = inboxParams => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@@ -43,11 +43,6 @@ export const state = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const throwErrorMessage = error => {
|
|
||||||
const errorMessage = parseAPIErrorResponse(error);
|
|
||||||
throw new Error(errorMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
getInboxes($state) {
|
getInboxes($state) {
|
||||||
return $state.records;
|
return $state.records;
|
||||||
|
|||||||
@@ -55,3 +55,8 @@ export const parseAPIErrorResponse = error => {
|
|||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const throwErrorMessage = error => {
|
||||||
|
const errorMessage = parseAPIErrorResponse(error);
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
getLoadingStatus,
|
getLoadingStatus,
|
||||||
parseAPIErrorResponse,
|
parseAPIErrorResponse,
|
||||||
setLoadingStatus,
|
setLoadingStatus,
|
||||||
|
throwErrorMessage,
|
||||||
} from '../api';
|
} from '../api';
|
||||||
|
|
||||||
describe('#getLoadingStatus', () => {
|
describe('#getLoadingStatus', () => {
|
||||||
@@ -37,3 +38,14 @@ describe('#parseAPIErrorResponse', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#throwErrorMessage', () => {
|
||||||
|
it('throws correct error', () => {
|
||||||
|
const errorFn = function throwErrorMessageFn() {
|
||||||
|
throwErrorMessage({
|
||||||
|
response: { data: { message: 'Error Message [message]' } },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
expect(errorFn).toThrow('Error Message [message]');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# auto_resolve_duration :integer
|
# auto_resolve_duration :integer
|
||||||
|
# custom_attributes :jsonb
|
||||||
# domain :string(100)
|
# domain :string(100)
|
||||||
# feature_flags :integer default(0), not null
|
# feature_flags :integer default(0), not null
|
||||||
# limits :jsonb
|
# limits :jsonb
|
||||||
|
|||||||
@@ -1,9 +1,2 @@
|
|||||||
json.id @account.id
|
json.partial! 'api/v1/models/account.json.jbuilder', resource: @account
|
||||||
json.name @account.name
|
|
||||||
json.locale @account.locale
|
|
||||||
json.domain @account.domain
|
|
||||||
json.custom_email_domain_enabled @account.custom_email_domain_enabled
|
|
||||||
json.support_email @account.support_email
|
|
||||||
json.features @account.all_features
|
|
||||||
json.auto_resolve_duration @account.auto_resolve_duration
|
|
||||||
json.latest_chatwoot_version @latest_chatwoot_version
|
json.latest_chatwoot_version @latest_chatwoot_version
|
||||||
|
|||||||
@@ -1,7 +1 @@
|
|||||||
json.id @account.id
|
json.partial! 'api/v1/models/account.json.jbuilder', resource: @account
|
||||||
json.name @account.name
|
|
||||||
json.locale @account.locale
|
|
||||||
json.domain @account.domain
|
|
||||||
json.custom_email_domain_enabled @account.custom_email_domain_enabled
|
|
||||||
json.support_email @account.support_email
|
|
||||||
json.features @account.enabled_features
|
|
||||||
|
|||||||
10
app/views/api/v1/models/_account.json.jbuilder
Normal file
10
app/views/api/v1/models/_account.json.jbuilder
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
json.auto_resolve_duration resource.auto_resolve_duration
|
||||||
|
json.created_at resource.created_at
|
||||||
|
json.custom_attributes resource.custom_attributes
|
||||||
|
json.custom_email_domain_enabled @account.custom_email_domain_enabled
|
||||||
|
json.domain @account.domain
|
||||||
|
json.features @account.enabled_features
|
||||||
|
json.id @account.id
|
||||||
|
json.locale @account.locale
|
||||||
|
json.name @account.name
|
||||||
|
json.support_email @account.support_email
|
||||||
3
config/initializers/stripe.rb
Normal file
3
config/initializers/stripe.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
require 'stripe'
|
||||||
|
|
||||||
|
Stripe.api_key = ENV.fetch('STRIPE_SECRET_KEY', nil)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddCustomAttributesToAccount < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :accounts, :custom_attributes, :jsonb, default: {}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_07_06_085458) do
|
ActiveRecord::Schema.define(version: 2022_07_18_123938) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
@@ -53,6 +53,7 @@ ActiveRecord::Schema.define(version: 2022_07_06_085458) do
|
|||||||
t.integer "feature_flags", default: 0, null: false
|
t.integer "feature_flags", default: 0, null: false
|
||||||
t.integer "auto_resolve_duration"
|
t.integer "auto_resolve_duration"
|
||||||
t.jsonb "limits", default: {}
|
t.jsonb "limits", default: {}
|
||||||
|
t.jsonb "custom_attributes", default: {}
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "action_mailbox_inbound_emails", force: :cascade do |t|
|
create_table "action_mailbox_inbound_emails", force: :cascade do |t|
|
||||||
|
|||||||
Reference in New Issue
Block a user