2020-05-10 17:10:36 +00:00
|
|
|
# loading installation configs
|
2020-06-22 07:49:26 +00:00
|
|
|
GlobalConfig.clear_cache
|
2020-05-10 17:10:36 +00:00
|
|
|
ConfigLoader.new.process
|
|
|
|
|
2021-01-17 08:37:18 +00:00
|
|
|
## Seeds productions
|
|
|
|
if Rails.env.production?
|
|
|
|
# Setup Onboarding flow
|
|
|
|
::Redis::Alfred.set(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
## Seeds for Local Development
|
|
|
|
unless Rails.env.production?
|
|
|
|
|
2022-08-31 19:01:43 +00:00
|
|
|
# Enables creating additional accounts from dashboard
|
|
|
|
installation_config = InstallationConfig.find_by(name: 'CREATE_NEW_ACCOUNT_FROM_DASHBOARD')
|
|
|
|
installation_config.value = true
|
|
|
|
installation_config.save!
|
|
|
|
GlobalConfig.clear_cache
|
|
|
|
|
2021-01-17 08:37:18 +00:00
|
|
|
account = Account.create!(
|
2021-03-04 08:29:59 +00:00
|
|
|
name: 'Acme Inc'
|
2021-01-17 08:37:18 +00:00
|
|
|
)
|
|
|
|
|
2021-06-08 17:15:01 +00:00
|
|
|
secondary_account = Account.create!(
|
|
|
|
name: 'Acme Org'
|
|
|
|
)
|
|
|
|
|
2022-01-26 00:58:49 +00:00
|
|
|
user = User.new(name: 'John', email: 'john@acme.inc', password: 'Password1!', type: 'SuperAdmin')
|
2021-01-17 08:37:18 +00:00
|
|
|
user.skip_confirmation!
|
|
|
|
user.save!
|
|
|
|
|
|
|
|
AccountUser.create!(
|
|
|
|
account_id: account.id,
|
|
|
|
user_id: user.id,
|
|
|
|
role: :administrator
|
|
|
|
)
|
|
|
|
|
2021-06-08 17:15:01 +00:00
|
|
|
AccountUser.create!(
|
|
|
|
account_id: secondary_account.id,
|
|
|
|
user_id: user.id,
|
|
|
|
role: :administrator
|
|
|
|
)
|
|
|
|
|
2021-01-17 08:37:18 +00:00
|
|
|
web_widget = Channel::WebWidget.create!(account: account, website_url: 'https://acme.inc')
|
|
|
|
|
|
|
|
inbox = Inbox.create!(channel: web_widget, account: account, name: 'Acme Support')
|
|
|
|
InboxMember.create!(user: user, inbox: inbox)
|
|
|
|
|
2021-04-28 15:23:23 +00:00
|
|
|
contact = Contact.create!(name: 'jane', email: 'jane@example.com', phone_number: '+2320000', account: account)
|
2021-01-21 19:31:02 +00:00
|
|
|
contact_inbox = ContactInbox.create!(inbox: inbox, contact: contact, source_id: user.id, hmac_verified: true)
|
2021-01-17 08:37:18 +00:00
|
|
|
conversation = Conversation.create!(
|
|
|
|
account: account,
|
|
|
|
inbox: inbox,
|
|
|
|
status: :open,
|
|
|
|
assignee: user,
|
|
|
|
contact: contact,
|
|
|
|
contact_inbox: contact_inbox,
|
|
|
|
additional_attributes: {}
|
|
|
|
)
|
2021-01-21 19:31:02 +00:00
|
|
|
|
|
|
|
# sample email collect
|
2021-11-26 19:18:46 +00:00
|
|
|
Seeders::MessageSeeder.create_sample_email_collect_message conversation
|
2021-01-21 19:31:02 +00:00
|
|
|
|
2021-01-17 08:37:18 +00:00
|
|
|
Message.create!(content: 'Hello', account: account, inbox: inbox, conversation: conversation, message_type: :incoming)
|
2021-01-21 19:31:02 +00:00
|
|
|
|
|
|
|
# sample card
|
2021-11-26 19:18:46 +00:00
|
|
|
Seeders::MessageSeeder.create_sample_cards_message conversation
|
2021-01-21 19:31:02 +00:00
|
|
|
# input select
|
2021-11-26 19:18:46 +00:00
|
|
|
Seeders::MessageSeeder.create_sample_input_select_message conversation
|
2021-01-21 19:31:02 +00:00
|
|
|
# form
|
2021-11-26 19:18:46 +00:00
|
|
|
Seeders::MessageSeeder.create_sample_form_message conversation
|
2021-01-21 19:31:02 +00:00
|
|
|
# articles
|
2021-11-26 19:18:46 +00:00
|
|
|
Seeders::MessageSeeder.create_sample_articles_message conversation
|
2021-06-22 07:31:19 +00:00
|
|
|
# csat
|
2021-11-26 19:18:46 +00:00
|
|
|
Seeders::MessageSeeder.create_sample_csat_collect_message conversation
|
2021-01-21 19:31:02 +00:00
|
|
|
|
2021-01-17 08:37:18 +00:00
|
|
|
CannedResponse.create!(account: account, short_code: 'start', content: 'Hello welcome to chatwoot.')
|
|
|
|
end
|