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:
@@ -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
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user