diff --git a/app/controllers/platform/api/v1/users_controller.rb b/app/controllers/platform/api/v1/users_controller.rb index 81b526c8e..b6e9237b9 100644 --- a/app/controllers/platform/api/v1/users_controller.rb +++ b/app/controllers/platform/api/v1/users_controller.rb @@ -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 diff --git a/app/views/platform/api/v1/models/_user.json.jbuilder b/app/views/platform/api/v1/models/_user.json.jbuilder new file mode 100644 index 000000000..8f7922aad --- /dev/null +++ b/app/views/platform/api/v1/models/_user.json.jbuilder @@ -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 diff --git a/app/views/platform/api/v1/users/create.json.jbuilder b/app/views/platform/api/v1/users/create.json.jbuilder new file mode 100644 index 000000000..46d8b6d34 --- /dev/null +++ b/app/views/platform/api/v1/users/create.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'platform/api/v1/models/user.json.jbuilder', resource: @resource diff --git a/app/views/platform/api/v1/users/show.json.jbuilder b/app/views/platform/api/v1/users/show.json.jbuilder new file mode 100644 index 000000000..46d8b6d34 --- /dev/null +++ b/app/views/platform/api/v1/users/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'platform/api/v1/models/user.json.jbuilder', resource: @resource diff --git a/app/views/platform/api/v1/users/update.json.jbuilder b/app/views/platform/api/v1/users/update.json.jbuilder new file mode 100644 index 000000000..46d8b6d34 --- /dev/null +++ b/app/views/platform/api/v1/users/update.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'platform/api/v1/models/user.json.jbuilder', resource: @resource diff --git a/config/features.yml b/config/features.yml index 70064255a..912b4c235 100644 --- a/config/features.yml +++ b/config/features.yml @@ -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 diff --git a/db/migrate/20210315101919_enable_email_channel.rb b/db/migrate/20210315101919_enable_email_channel.rb new file mode 100644 index 000000000..194a4c5a3 --- /dev/null +++ b/db/migrate/20210315101919_enable_email_channel.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 264ff1534..13c8a69a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"