Skip to content

Commit

Permalink
Refactor for notify_status_change (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
enderahmetyurt authored and pranavrajs committed Oct 5, 2019
1 parent b41a8c8 commit ca63bba
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions app/models/conversation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,21 @@ def activity_message_params content
end

def notify_status_change
if status_changed?
if resolved? && assignee.present?
$dispatcher.dispatch(CONVERSATION_RESOLVED, Time.zone.now, conversation: self)
end
end
if user_last_seen_at_changed?
$dispatcher.dispatch(CONVERSATION_READ, Time.zone.now, conversation: self)
end
if locked_changed?
$dispatcher.dispatch(CONVERSATION_LOCK_TOGGLE, Time.zone.now, conversation: self)
end
if assignee_id_changed?
$dispatcher.dispatch(ASSIGNEE_CHANGED, Time.zone.now, conversation: self)
resolve_conversation if status_changed?
dispatcher_dispatch(CONVERSATION_READ) if user_last_seen_at_changed?
dispatcher_dispatch(CONVERSATION_LOCK_TOGGLE) if locked_changed?
dispatcher_dispatch(ASSIGNEE_CHANGED) if assignee_id_changed?
end

def resolve_conversation
if resolved? && assignee.present?
dispatcher_dispatch(CONVERSATION_RESOLVED)
end
end

def dispatcher_dispatch(event_name)
$dispatcher.dispatch(event_name, Time.zone.now, conversation: self)
end

def run_round_robin
if true #conversation.account.has_feature?(round_robin)
Expand Down

0 comments on commit ca63bba

Please sign in to comment.