Chore: Web widget Inbox Tech Debts (#738)

* Chore: Webwidget Inbox Tech Debts

* Additional customization options creating Web Widget
* Changes to edit Page for Web Widget
* Remove the WebWidget API end points
* Minor chores

Address: #680, #502

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2020-04-19 23:40:28 +05:30
committed by GitHub
parent c0ce70e87b
commit 941fbb0d72
46 changed files with 564 additions and 503 deletions

View File

@@ -3,7 +3,6 @@
# Table name: channel_facebook_pages
#
# id :integer not null, primary key
# name :string not null
# page_access_token :string not null
# user_access_token :string not null
# created_at :datetime not null
@@ -18,23 +17,19 @@
#
class Channel::FacebookPage < ApplicationRecord
# FIXME: this should be removed post 1.4 release. we moved avatars to inbox
include Avatarable
self.table_name = 'channel_facebook_pages'
validates :account_id, presence: true
validates :page_id, uniqueness: { scope: :account_id }
has_one_attached :avatar
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
before_destroy :unsubscribe
def name
'Facebook'
end
private
def unsubscribe

View File

@@ -3,7 +3,6 @@
# Table name: channel_twitter_profiles
#
# id :bigint not null, primary key
# name :string
# twitter_access_token :string not null
# twitter_access_token_secret :string not null
# created_at :datetime not null
@@ -21,17 +20,12 @@ class Channel::TwitterProfile < ApplicationRecord
validates :account_id, presence: true
validates :profile_id, uniqueness: { scope: :account_id }
has_one_attached :avatar
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
before_destroy :unsubscribe
def name
'Twitter'
end
def create_contact_inbox(profile_id, name, additional_attributes)
ActiveRecord::Base.transaction do
contact = inbox.account.contacts.create!(additional_attributes: additional_attributes, name: name)

View File

@@ -2,14 +2,16 @@
#
# Table name: channel_web_widgets
#
# id :integer not null, primary key
# website_name :string
# website_token :string
# website_url :string
# widget_color :string default("#1f93ff")
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer
# id :integer not null, primary key
# agent_away_message :string
# website_token :string
# website_url :string
# welcome_tagline :string
# welcome_title :string
# widget_color :string default("#1f93ff")
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer
#
# Indexes
#
@@ -19,7 +21,6 @@
class Channel::WebWidget < ApplicationRecord
self.table_name = 'channel_web_widgets'
validates :website_name, presence: true
validates :website_url, presence: true
validates :widget_color, presence: true
@@ -27,10 +28,6 @@ class Channel::WebWidget < ApplicationRecord
has_one :inbox, as: :channel, dependent: :destroy
has_secure_token :website_token
def name
'Website'
end
def web_widget_script
"<script>
(function(d,t) {

View File

@@ -25,10 +25,10 @@ class NotificationSetting < ApplicationRecord
flag_query_mode: :bit_operator
}.freeze
EMAIL_NOTIFCATION_FLAGS = {
EMAIL_NOTIFICATION_FLAGS = {
1 => :conversation_creation,
2 => :conversation_assignment
}.freeze
has_flags EMAIL_NOTIFCATION_FLAGS.merge(column: 'email_flags').merge(DEFAULT_QUERY_SETTING)
has_flags EMAIL_NOTIFICATION_FLAGS.merge(column: 'email_flags').merge(DEFAULT_QUERY_SETTING)
end