chore: Move agent availability to Account level (#3074)
- Move agent availability to the account level
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
|
||||
class User < ApplicationRecord
|
||||
include AccessTokenable
|
||||
include AvailabilityStatusable
|
||||
include Avatarable
|
||||
# Include default devise modules.
|
||||
include DeviseTokenAuth::Concerns::User
|
||||
@@ -57,6 +56,8 @@ class User < ApplicationRecord
|
||||
:confirmable,
|
||||
:password_has_required_content
|
||||
|
||||
# TODO: remove in a future version once online status is moved to account users
|
||||
# remove the column availability from users
|
||||
enum availability: { online: 0, offline: 1, busy: 2 }
|
||||
|
||||
# The validation below has been commented out as it does not
|
||||
@@ -89,8 +90,6 @@ class User < ApplicationRecord
|
||||
|
||||
before_validation :set_password_and_uid, on: :create
|
||||
|
||||
after_save :update_presence_in_redis, if: :saved_change_to_availability?
|
||||
|
||||
scope :order_by_full_name, -> { order('lower(name) ASC') }
|
||||
|
||||
def send_devise_notification(notification, *args)
|
||||
@@ -141,6 +140,14 @@ class User < ApplicationRecord
|
||||
current_account_user&.role
|
||||
end
|
||||
|
||||
def availability_status
|
||||
current_account_user&.availability_status
|
||||
end
|
||||
|
||||
def auto_offline
|
||||
current_account_user&.auto_offline
|
||||
end
|
||||
|
||||
def inviter
|
||||
current_account_user&.inviter
|
||||
end
|
||||
@@ -169,12 +176,4 @@ class User < ApplicationRecord
|
||||
type: 'user'
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_presence_in_redis
|
||||
accounts.each do |account|
|
||||
OnlineStatusTracker.set_status(account.id, id, availability)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user