chore: Clean up assignment logic (#3763)
This commit is contained in:
@@ -4,7 +4,7 @@ module AssignmentHandler
|
|||||||
|
|
||||||
included do
|
included do
|
||||||
before_save :ensure_assignee_is_from_team
|
before_save :ensure_assignee_is_from_team
|
||||||
after_update :notify_assignment_change, :process_assignment_activities
|
after_commit :notify_assignment_change, :process_assignment_activities
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class Notification < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
# TODO: move to a data presenter
|
# TODO: move to a data presenter
|
||||||
|
# rubocop:disable Metrics/CyclomaticComplexity
|
||||||
def push_message_title
|
def push_message_title
|
||||||
case notification_type
|
case notification_type
|
||||||
when 'conversation_creation'
|
when 'conversation_creation'
|
||||||
@@ -81,14 +82,15 @@ class Notification < ApplicationRecord
|
|||||||
I18n.t(
|
I18n.t(
|
||||||
'notifications.notification_title.assigned_conversation_new_message',
|
'notifications.notification_title.assigned_conversation_new_message',
|
||||||
display_id: conversation.display_id,
|
display_id: conversation.display_id,
|
||||||
content: primary_actor.content&.truncate_words(10)
|
content: primary_actor&.content&.truncate_words(10)
|
||||||
)
|
)
|
||||||
when 'conversation_mention'
|
when 'conversation_mention'
|
||||||
"[##{conversation.display_id}] #{transform_user_mention_content primary_actor.content}"
|
"[##{conversation&.display_id}] #{transform_user_mention_content primary_actor&.content}"
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
def conversation
|
def conversation
|
||||||
return primary_actor.conversation if %w[assigned_conversation_new_message conversation_mention].include? notification_type
|
return primary_actor.conversation if %w[assigned_conversation_new_message conversation_mention].include? notification_type
|
||||||
|
|||||||
Reference in New Issue
Block a user