feat: add activity message for priority change (#6933)

* feat: add priority const

* feat: add toggle priority method

* feat: update controller route and specs

* refactor: status change method

* refactor: abstract label change and mute activity

* feat: add priority change_activity

* fix: interpolation for previous_changes

* refactor: reduce cognitive complexity of priority_change_activity

* refactor: move priority activity message handler to a separate module

* refactor: move typing logic to a service

* refactor: tests to reduce complexity

* fix: typo

* fix: constants

* fix: priority conditions

* fix: add a response

* fix: argument destructuring in I18n.t

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2023-04-20 16:41:53 +05:30
committed by GitHub
parent 6b2736aa63
commit a34729c153
11 changed files with 217 additions and 54 deletions

View File

@@ -0,0 +1,26 @@
class Conversations::TypingStatusManager
include Events::Types
attr_reader :conversation, :user, :params
def initialize(conversation, user, params)
@conversation = conversation
@user = user
@params = params
end
def trigger_typing_event(event, is_private)
user = @user.presence || @resource
Rails.configuration.dispatcher.dispatch(event, Time.zone.now, conversation: @conversation, user: user, is_private: is_private)
end
def toggle_typing_status
case params[:typing_status]
when 'on'
trigger_typing_event(CONVERSATION_TYPING_ON, params[:is_private])
when 'off'
trigger_typing_event(CONVERSATION_TYPING_OFF, params[:is_private])
end
# Return the head :ok response from the controller
end
end