chore: Apply fixes for items in rubocop_todo [CW-1806] (#8864)
This PR addresses several items listed in our rubocop_todo by implementing the necessary corrections and enhancements. As a result, we are now able to remove the rubocop_todo file entirely, streamlining our codebase and ensuring adherence to our coding standards. fixes: https://linear.app/chatwoot/issue/CW-1806/chore-rubocop-audit
This commit is contained in:
@@ -118,7 +118,7 @@ class Message < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :inbox
|
||||
belongs_to :conversation, touch: true
|
||||
belongs_to :sender, polymorphic: true, required: false
|
||||
belongs_to :sender, polymorphic: true, optional: true
|
||||
|
||||
has_many :attachments, dependent: :destroy, autosave: true, before_add: :validate_attachments_limit
|
||||
has_one :csat_survey_response, dependent: :destroy_async
|
||||
@@ -139,8 +139,8 @@ class Message < ApplicationRecord
|
||||
conversation_id: conversation.display_id,
|
||||
conversation: conversation_push_event_data
|
||||
)
|
||||
data.merge!(echo_id: echo_id) if echo_id.present?
|
||||
data.merge!(attachments: attachments.map(&:push_event_data)) if attachments.present?
|
||||
data[:echo_id] = echo_id if echo_id.present?
|
||||
data[:attachments] = attachments.map(&:push_event_data) if attachments.present?
|
||||
merge_sender_attributes(data)
|
||||
end
|
||||
|
||||
@@ -163,8 +163,8 @@ class Message < ApplicationRecord
|
||||
end
|
||||
|
||||
def merge_sender_attributes(data)
|
||||
data.merge!(sender: sender.push_event_data) if sender && !sender.is_a?(AgentBot)
|
||||
data.merge!(sender: sender.push_event_data(inbox)) if sender.is_a?(AgentBot)
|
||||
data[:sender] = sender.push_event_data if sender && !sender.is_a?(AgentBot)
|
||||
data[:sender] = sender.push_event_data(inbox) if sender.is_a?(AgentBot)
|
||||
data
|
||||
end
|
||||
|
||||
@@ -184,7 +184,7 @@ class Message < ApplicationRecord
|
||||
sender: sender.try(:webhook_data),
|
||||
source_id: source_id
|
||||
}
|
||||
data.merge!(attachments: attachments.map(&:push_event_data)) if attachments.present?
|
||||
data[:attachments] = attachments.map(&:push_event_data) if attachments.present?
|
||||
data
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user