rocketchat 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9dd649b2ce883c528aaaa759be25034b0bf112b4c5e21ac3c9202fab78a6baa
4
- data.tar.gz: 23e96835f8b14e4601b78bc10506ee222665acc5409b45380572007db067f765
3
+ metadata.gz: c8dcf3e2e38671372e85fa5f8791ef9014ee5e7a506fa8b4ab896e4e6658afea
4
+ data.tar.gz: ac550d2d5baae28a8dfa2337c67ae4498b05871c9b5089ae57f1dd07cf6aecd7
5
5
  SHA512:
6
- metadata.gz: 9977334377d472e5e51b941f4cf359473b588d2572965bde362d79ffe09e3afc8defdfd47904a32e1e12e47f368917447dc8710227c24d76155d74ea6ee301be
7
- data.tar.gz: 82fe7597f43165cedeae9328e2cf8145d9bc5cc0b39f924dfed7580262c1e112a010e5e5711ca74396ee494ffb7855e6aae51adb8c7f6790f7117be54b297569
6
+ metadata.gz: ab31a6c39910bb896658c1ea78342a25b6dcaf1e931260700871ff3b6e90b343a781175cc1115df260e2ce03b7a30373c28c446dc5e02455dc2e5abb62c720e2
7
+ data.tar.gz: 6c173e1f07a55d49ffad6d0c8f9db83b6b0d29340ca475bf0fcfc1792e5f3b5d20af7d1d9fb3f0aa32f059fe963924c35007748082132f6949dd9441d2c8d16b
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  ## Unreleased
4
4
  - None
5
5
 
6
+ ## [0.2.4](releases/tag/v0.2.4) - 2023-12-22
7
+ ### Added
8
+ - [#47] Add content-type and filename params for file upload ([@MrRTI][])
9
+
6
10
  ## [0.2.3](releases/tag/v0.2.3) - 2023-08-22
7
11
  ### Added
8
12
  - [#46] Add file upload support using rooms.upload endpoint ([@MrRTI][])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RocketChat
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
@@ -319,7 +319,7 @@ module RocketChat
319
319
  response = session.request_json(
320
320
  "#{API_PREFIX}/rooms.upload/#{room_id}",
321
321
  method: :post,
322
- form_data: file_upload_hash(file: file, **rest_params)
322
+ form_data: file_upload_array(file: file, **rest_params)
323
323
  )
324
324
 
325
325
  RocketChat::Message.new response['message'] if response['success']
@@ -345,9 +345,17 @@ module RocketChat
345
345
  self.class.settable_attributes.include?(attribute)
346
346
  end
347
347
 
348
- def file_upload_hash(**params)
348
+ def file_upload_array(**params)
349
349
  permited_keys_for_file_upload = %i[file msg description tmid]
350
- Util.slice_hash(params, *permited_keys_for_file_upload)
350
+ hash = Util.slice_hash(params, *permited_keys_for_file_upload).compact
351
+
352
+ # NOTE: https://docs.ruby-lang.org/en/master/Net/HTTPHeader.html#method-i-set_form
353
+ file_options = params.slice(:filename, :content_type).compact
354
+ hash.map do |key, value|
355
+ next [key.to_s, value, file_options] if key == :file && file_options.keys.any?
356
+
357
+ [key.to_s, value]
358
+ end
351
359
  end
352
360
  end
353
361
  end
@@ -110,7 +110,7 @@ module RocketChat
110
110
  req = Net::HTTP::Post.new(path, headers)
111
111
  add_body(req, body) if body
112
112
 
113
- form_data = reject_nils(options[:form_data])
113
+ form_data = options[:form_data]
114
114
  add_form_data(req, form_data) if form_data
115
115
  else
116
116
  uri = path
@@ -131,7 +131,6 @@ module RocketChat
131
131
  end
132
132
 
133
133
  def add_form_data(request, form_data)
134
- form_data = form_data.transform_keys(&:to_s) if form_data.is_a? Hash
135
134
  request.set_form(form_data, 'multipart/form-data')
136
135
  end
137
136
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - int512
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-08-22 00:00:00.000000000 Z
12
+ date: 2023-12-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rocket.Chat REST API v1 for Ruby
15
15
  email: