Class: CustomerServiceIm::Staff
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- CustomerServiceIm::Staff
- Defined in:
- app/models/customer_service_im/staff.rb
Class Method Summary collapse
Instance Method Summary collapse
- #join_conversation(conversation) ⇒ Object
- #offline! ⇒ Object
- #offline? ⇒ Boolean
- #online! ⇒ Object
- #online? ⇒ Boolean
Class Method Details
.online_staffs ⇒ Object
19 20 21 |
# File 'app/models/customer_service_im/staff.rb', line 19 def self.online_staffs where(id: online_staffs_ids) end |
Instance Method Details
#join_conversation(conversation) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/models/customer_service_im/staff.rb', line 10 def join_conversation(conversation) conversation.update(staff: self) conversation..from_user.each do || .update(staff: self) .broadcast_to_conversation end end |
#offline! ⇒ Object
27 28 29 |
# File 'app/models/customer_service_im/staff.rb', line 27 def offline! redis.srem self.class.online_staff_redis_key, as_redis_record end |
#offline? ⇒ Boolean
35 36 37 |
# File 'app/models/customer_service_im/staff.rb', line 35 def offline? !online? end |
#online! ⇒ Object
23 24 25 |
# File 'app/models/customer_service_im/staff.rb', line 23 def online! redis.sadd self.class.online_staff_redis_key, as_redis_record end |
#online? ⇒ Boolean
31 32 33 |
# File 'app/models/customer_service_im/staff.rb', line 31 def online? id.in? self.class.online_staffs_ids end |