From 512464cb99c1a0d204c9cf33664fa61f6b759673 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Fri, 24 Nov 2023 11:50:11 -0500 Subject: [PATCH] Fixed issue when sending message without attachments (#437) This PR fixes a bug that arises when sending messages and creating or modifying drafts without any attachments present. --- CHANGELOG.md | 3 +++ lib/nylas/utils/file_utils.rb | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 003ec1b8..1574255b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 6.0.0-beta.3 / TBD +* Fixed issue when sending message without attachments + ### 6.0.0-beta.2 / 2023-11-21 * Added additional error classes * Added support for free/busy endpoint diff --git a/lib/nylas/utils/file_utils.rb b/lib/nylas/utils/file_utils.rb index 75b15d66..01514a14 100644 --- a/lib/nylas/utils/file_utils.rb +++ b/lib/nylas/utils/file_utils.rb @@ -11,9 +11,14 @@ module FileUtils # @!visibility private def self.build_form_request(request_body) attachments = request_body.delete(:attachments) || request_body.delete("attachments") || [] - message_payload = request_body.to_json + + # RestClient will not send a multipart request if there are no attachments + # so we need to return the message payload to be used as a json payload + return [request_body, []] if attachments.empty? # Prepare the data to return + message_payload = request_body.to_json + form_data = {} opened_files = []