Skip to content

Commit

Permalink
Fixed issue when sending message without attachments (#437)
Browse files Browse the repository at this point in the history
This PR fixes a bug that arises when sending messages and creating or modifying drafts without any attachments present.
  • Loading branch information
mrashed-dev authored Nov 24, 2023
1 parent da67fbe commit 512464c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/nylas/utils/file_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down

0 comments on commit 512464c

Please sign in to comment.