Fix: attachment name for incoming messages

Use original_filename to get the name of the file attached to the message.

Had to add the message_type method to the WhatsApp/incoming_message_service due to the Assignment Branch Condition linter error for the attach_files method.

Fixes #4183
This commit is contained in:
Shivam Chahar
2022-04-28 21:02:17 +05:30
committed by GitHub
parent 8d04894744
commit 04194e7247
3 changed files with 7 additions and 4 deletions

View File

@@ -87,7 +87,7 @@ class Sms::IncomingMessageService
file_type: file_type(attachment_file.content_type),
file: {
io: attachment_file,
filename: attachment_file,
filename: attachment_file.original_filename,
content_type: attachment_file.content_type
}
)

View File

@@ -105,7 +105,7 @@ class Telegram::IncomingMessageService
file_type: file_content_type,
file: {
io: attachment_file,
filename: attachment_file,
filename: attachment_file.original_filename,
content_type: attachment_file.content_type
}
)

View File

@@ -77,7 +77,6 @@ class Whatsapp::IncomingMessageService
end
def attach_files
message_type = params[:messages].first[:type]
return if %w[text button interactive].include?(message_type)
attachment_payload = params[:messages].first[message_type.to_sym]
@@ -89,9 +88,13 @@ class Whatsapp::IncomingMessageService
file_type: file_content_type(message_type),
file: {
io: attachment_file,
filename: attachment_file,
filename: attachment_file.original_filename,
content_type: attachment_file.content_type
}
)
end
def message_type
params[:messages].first[:type]
end
end