From 3d27ae25c6116e0190bb02b47efe1260d7beefbb Mon Sep 17 00:00:00 2001 From: Sojan Date: Thu, 5 Jun 2025 16:27:04 -0500 Subject: [PATCH] chore: codeclimate fixes --- app/models/attachment.rb | 18 ++++++++++++++---- .../conversation/response_builder_job.rb | 4 +--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0bfd9a978..4f942a1d9 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -44,11 +44,8 @@ class Attachment < ApplicationRecord def push_event_data return unless file_type - return base_data.merge(location_metadata) if file_type.to_sym == :location - return base_data.merge(fallback_data) if file_type.to_sym == :fallback - return base_data.merge(contact_metadata) if file_type.to_sym == :contact - base_data.merge(file_metadata) + base_data.merge(metadata_for_file_type) end # NOTE: the URl returned does a 301 redirect to the actual file @@ -76,6 +73,19 @@ class Attachment < ApplicationRecord private + def metadata_for_file_type + case file_type.to_sym + when :location + location_metadata + when :fallback + fallback_data + when :contact + contact_metadata + else + file_metadata + end + end + def file_metadata metadata = { extension: extension, diff --git a/enterprise/app/jobs/captain/conversation/response_builder_job.rb b/enterprise/app/jobs/captain/conversation/response_builder_job.rb index c661caebe..17532525a 100644 --- a/enterprise/app/jobs/captain/conversation/response_builder_job.rb +++ b/enterprise/app/jobs/captain/conversation/response_builder_job.rb @@ -50,9 +50,7 @@ class Captain::Conversation::ResponseBuilderJob < ApplicationJob def message_content(message) return message.content if message.content.present? - return 'User has shared an attachment' if message.attachments.any? - - 'User has shared a message without content' + message.attachments.any? ? 'User has shared an attachment' : 'User has shared a message without content' end def determine_role(message)