Chore: Add display name to the user (#1067)
* Chore: Adding browser info to web widget triggered event fixes: #970 * Chore: Rename nickname to display name references: #972 * Chore: Change nickname in code * chore: fix errors * Chore: update nginx config fixes: #1057 * Chore: Fix specs
This commit is contained in:
parent
29838f9424
commit
d800b55ac6
13 changed files with 34 additions and 23 deletions
|
@ -30,4 +30,14 @@ class Api::V1::Widget::BaseController < ApplicationController
|
||||||
)
|
)
|
||||||
@contact = @contact_inbox.contact
|
@contact = @contact_inbox.contact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def browser_params
|
||||||
|
{
|
||||||
|
browser_name: browser.name,
|
||||||
|
browser_version: browser.full_version,
|
||||||
|
device_name: browser.device.name,
|
||||||
|
platform_name: browser.platform.name,
|
||||||
|
platform_version: browser.platform.version
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,8 @@ class Api::V1::Widget::EventsController < Api::V1::Widget::BaseController
|
||||||
def event_info
|
def event_info
|
||||||
{
|
{
|
||||||
widget_language: params[:locale],
|
widget_language: params[:locale],
|
||||||
browser_language: browser.accept_language.first&.code
|
browser_language: browser.accept_language.first&.code,
|
||||||
|
browser: browser_params
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -66,16 +66,6 @@ class Api::V1::Widget::MessagesController < Api::V1::Widget::BaseController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def browser_params
|
|
||||||
{
|
|
||||||
browser_name: browser.name,
|
|
||||||
browser_version: browser.full_version,
|
|
||||||
device_name: browser.device.name,
|
|
||||||
platform_name: browser.platform.name,
|
|
||||||
platform_version: browser.platform.version
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def timestamp_params
|
def timestamp_params
|
||||||
{
|
{
|
||||||
timestamp: permitted_params[:message][:timestamp]
|
timestamp: permitted_params[:message][:timestamp]
|
||||||
|
|
|
@ -24,7 +24,7 @@ class UserDashboard < Administrate::BaseDashboard
|
||||||
confirmation_sent_at: Field::DateTime,
|
confirmation_sent_at: Field::DateTime,
|
||||||
unconfirmed_email: Field::String,
|
unconfirmed_email: Field::String,
|
||||||
name: Field::String,
|
name: Field::String,
|
||||||
nickname: Field::String,
|
display_name: Field::String,
|
||||||
email: Field::String,
|
email: Field::String,
|
||||||
tokens: Field::String.with_options(searchable: false),
|
tokens: Field::String.with_options(searchable: false),
|
||||||
created_at: Field::DateTime,
|
created_at: Field::DateTime,
|
||||||
|
@ -53,7 +53,7 @@ class UserDashboard < Administrate::BaseDashboard
|
||||||
avatar_url
|
avatar_url
|
||||||
unconfirmed_email
|
unconfirmed_email
|
||||||
name
|
name
|
||||||
nickname
|
display_name
|
||||||
email
|
email
|
||||||
created_at
|
created_at
|
||||||
updated_at
|
updated_at
|
||||||
|
@ -65,7 +65,7 @@ class UserDashboard < Administrate::BaseDashboard
|
||||||
# on the model's form (`new` and `edit`) pages.
|
# on the model's form (`new` and `edit`) pages.
|
||||||
FORM_ATTRIBUTES = %i[
|
FORM_ATTRIBUTES = %i[
|
||||||
name
|
name
|
||||||
nickname
|
display_name
|
||||||
email
|
email
|
||||||
password
|
password
|
||||||
].freeze
|
].freeze
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
# confirmed_at :datetime
|
# confirmed_at :datetime
|
||||||
# current_sign_in_at :datetime
|
# current_sign_in_at :datetime
|
||||||
# current_sign_in_ip :string
|
# current_sign_in_ip :string
|
||||||
|
# display_name :string
|
||||||
# email :string
|
# email :string
|
||||||
# encrypted_password :string default(""), not null
|
# encrypted_password :string default(""), not null
|
||||||
# last_sign_in_at :datetime
|
# last_sign_in_at :datetime
|
||||||
# last_sign_in_ip :string
|
# last_sign_in_ip :string
|
||||||
# name :string not null
|
# name :string not null
|
||||||
# nickname :string
|
|
||||||
# provider :string default("email"), not null
|
# provider :string default("email"), not null
|
||||||
# pubsub_token :string
|
# pubsub_token :string
|
||||||
# remember_created_at :datetime
|
# remember_created_at :datetime
|
||||||
|
@ -96,6 +96,10 @@ class User < ApplicationRecord
|
||||||
account_users.find_by(account_id: Current.account.id) if Current.account
|
account_users.find_by(account_id: Current.account.id) if Current.account
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def display_name
|
||||||
|
self[:display_name].presence || name
|
||||||
|
end
|
||||||
|
|
||||||
def account
|
def account
|
||||||
current_account_user&.account
|
current_account_user&.account
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ json.id resource.id
|
||||||
json.provider resource.provider
|
json.provider resource.provider
|
||||||
json.uid resource.uid
|
json.uid resource.uid
|
||||||
json.name resource.name
|
json.name resource.name
|
||||||
json.nickname resource.nickname
|
json.display_name resource.display_name
|
||||||
json.email resource.email
|
json.email resource.email
|
||||||
json.account_id resource.active_account_user&.account_id
|
json.account_id resource.active_account_user&.account_id
|
||||||
json.pubsub_token resource.pubsub_token
|
json.pubsub_token resource.pubsub_token
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenameNickNameToDisplayName < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
rename_column :users, :nickname, :display_name
|
||||||
|
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: 2020_07_09_145000) do
|
ActiveRecord::Schema.define(version: 2020_07_19_171437) 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"
|
||||||
|
@ -407,7 +407,7 @@ ActiveRecord::Schema.define(version: 2020_07_09_145000) do
|
||||||
t.datetime "confirmation_sent_at"
|
t.datetime "confirmation_sent_at"
|
||||||
t.string "unconfirmed_email"
|
t.string "unconfirmed_email"
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.string "nickname"
|
t.string "display_name"
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.json "tokens"
|
t.json "tokens"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
|
|
@ -32,6 +32,7 @@ server {
|
||||||
server_name yourdomain.com;
|
server_name yourdomain.com;
|
||||||
# where rails app is running
|
# where rails app is running
|
||||||
set $upstream 127.0.0.1:3000;
|
set $upstream 127.0.0.1:3000;
|
||||||
|
underscores_in_headers on;
|
||||||
|
|
||||||
# Here we define the web-root for our SSL proof
|
# Here we define the web-root for our SSL proof
|
||||||
location /.well-known {
|
location /.well-known {
|
||||||
|
|
|
@ -32,7 +32,7 @@ RSpec.describe '/api/v1/widget/events', type: :request do
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(Rails.configuration.dispatcher).to have_received(:dispatch)
|
expect(Rails.configuration.dispatcher).to have_received(:dispatch)
|
||||||
.with(params[:name], anything, contact_inbox: contact_inbox,
|
.with(params[:name], anything, contact_inbox: contact_inbox,
|
||||||
event_info: { browser_language: nil, widget_language: nil })
|
event_info: { browser_language: nil, widget_language: nil, browser: anything })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,8 +12,8 @@ FactoryBot.define do
|
||||||
provider { 'email' }
|
provider { 'email' }
|
||||||
uid { SecureRandom.uuid }
|
uid { SecureRandom.uuid }
|
||||||
name { Faker::Name.name }
|
name { Faker::Name.name }
|
||||||
nickname { Faker::Name.first_name }
|
display_name { Faker::Name.first_name }
|
||||||
email { nickname + "@#{SecureRandom.uuid}.com" }
|
email { display_name + "@#{SecureRandom.uuid}.com" }
|
||||||
password { 'password' }
|
password { 'password' }
|
||||||
|
|
||||||
after(:build) do |user, evaluator|
|
after(:build) do |user, evaluator|
|
||||||
|
|
|
@ -15,5 +15,5 @@ properties:
|
||||||
enum: ['agent', 'administrator']
|
enum: ['agent', 'administrator']
|
||||||
confirmed:
|
confirmed:
|
||||||
type: boolean
|
type: boolean
|
||||||
nickname:
|
display_name:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -1087,7 +1087,7 @@
|
||||||
"confirmed": {
|
"confirmed": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"nickname": {
|
"display_name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue