Chore: Migration to enable email channel (#1913)

fixes: #1877
This commit is contained in:
Sojan Jose 2021-03-15 19:15:48 +05:30 committed by GitHub
parent 3fd398879e
commit b6f4006c15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 7 deletions

View file

@ -10,20 +10,16 @@ class Platform::Api::V1::UsersController < PlatformController
@resource.confirm
@resource.save!
@platform_app.platform_app_permissibles.find_or_create_by(permissible: @resource)
render json: @resource
end
def login
render json: { url: "#{ENV['FRONTEND_URL']}/app/login?email=#{@resource.email}&sso_auth_token=#{@resource.generate_sso_auth_token}" }
end
def show
render json: @resource
end
def show; end
def update
@resource.update!(user_params)
render json: @resource
end
def destroy

View file

@ -0,0 +1,23 @@
json.access_token resource.access_token.token
json.account_id resource.active_account_user&.account_id
json.availability_status resource.availability_status
json.available_name resource.available_name
json.avatar_url resource.avatar_url
json.confirmed resource.confirmed?
json.display_name resource.display_name
json.email resource.email
json.id resource.id
json.name resource.name
json.provider resource.provider
json.pubsub_token resource.pubsub_token
json.role resource.active_account_user&.role
json.ui_settings resource.ui_settings
json.uid resource.uid
json.accounts do
json.array! resource.account_users do |account_user|
json.id account_user.account_id
json.name account_user.account.name
json.active_at account_user.active_at
json.role account_user.role
end
end

View file

@ -0,0 +1 @@
json.partial! 'platform/api/v1/models/user.json.jbuilder', resource: @resource

View file

@ -0,0 +1 @@
json.partial! 'platform/api/v1/models/user.json.jbuilder', resource: @resource

View file

@ -0,0 +1 @@
json.partial! 'platform/api/v1/models/user.json.jbuilder', resource: @resource

View file

@ -1,6 +1,6 @@
# DO NOT change the order of features EVER
- name: inbound_emails
enabled: false
enabled: true
- name: channel_email
enabled: true
- name: channel_facebook

View file

@ -0,0 +1,17 @@
class EnableEmailChannel < ActiveRecord::Migration[6.0]
def change
current_config = InstallationConfig.where(name: 'ACCOUNT_LEVEL_FEATURE_DEFAULTS').last
current_config.value.each { |v| v['enabled'] = true if %w[inbound_emails channel_email].include?(v['name']) }
current_config.save!
ConfigLoader.new.process
Account.find_in_batches do |account_batch|
account_batch.each do |account|
account.enable_features('inbound_emails')
account.enable_features('channel_email')
account.save!
end
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_03_03_192243) do
ActiveRecord::Schema.define(version: 2021_03_15_101919) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"