Routine weeding of the codebase (#163)

* Routine weeding of the codebase
* fix the spec
This commit is contained in:
Sojan Jose
2019-10-20 16:19:12 +05:30
committed by GitHub
parent 94c6d6db6f
commit 2099dc01a6
16 changed files with 228 additions and 244 deletions

View File

@@ -1,3 +0,0 @@
class Channel < ApplicationRecord
has_many :conversations
end

View File

@@ -0,0 +1,26 @@
module Channel
class FacebookPage < ApplicationRecord
self.table_name = 'channel_facebook_pages'
validates :account_id, presence: true
validates_uniqueness_of :page_id, scope: :account_id
mount_uploader :avatar, AvatarUploader
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
before_destroy :unsubscribe
def name
`Facebook`
end
private
def unsubscribe
Facebook::Messenger::Subscriptions.unsubscribe(access_token: page_access_token)
rescue => e
true
end
end
end

View File

@@ -0,0 +1,8 @@
module Channel
class WebWidget < ApplicationRecord
self.table_name = 'channel_web_widgets'
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
end
end

View File

@@ -1,4 +0,0 @@
class Channel::Widget < ApplicationRecord
belongs_to :account
has_one :inbox, as: :channel, dependent: :destroy
end

View File

@@ -25,7 +25,7 @@ class Inbox < ApplicationRecord
end
def facebook?
channel.class.name.to_s == 'FacebookPage'
channel.class.name.to_s == 'Channel::FacebookPage'
end
def next_available_agent