matrix_sdk 2.1.1 → 2.1.2

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: 487904c24bd70f3d0412ba040f84687d6ef7a6bfe570d259f6d5d73fe7194128
4
- data.tar.gz: 7d6f53ba5ec1e1426c5bd274e0809f0edcb67a8e8a355b1dd6d409ac57ee3e0f
3
+ metadata.gz: 5af1e7af0f473a5c44df1ede83655cdbdb120e215e42f125b6af576740b88aa6
4
+ data.tar.gz: cca80fe97ca22f0ddb0c5a2b39b24b70345baa25fb20bea305fa019f46ca7d3a
5
5
  SHA512:
6
- metadata.gz: cfbaff099abec9777a5593fa1646ff5e4285fc246894f850b000834185d352f024e8bc9340c17554da6e73c056db9f327bd98f27c259d123ceadf78977203ed0
7
- data.tar.gz: f53ec1ca41f8884a8916609f364db9fd849b8957629c1f46cfaa440910030035d6f4c92de464aaabd3dc3d207ccf47e9bedccce30980ab213a625d5bb4e13473
6
+ metadata.gz: 0e4c694d8489dae1b2602d01f4aab08b20119c6697e83b41a2a463adb7ebcaf7b1afd439db04a6e54a0979c5a93be865c8afa3d2d03b4ca34b98f82afae87a5f
7
+ data.tar.gz: 8f52c12d1eb8af55ac5bc011852c9d5f648e9de1cc3241ea1ed76530036b02cff373cb69b8a4c721956add3df1359377d79b2fa2562e8dab8efe5ce877596e2d
@@ -1,3 +1,10 @@
1
+ ## 2.1.2 - 2020-09-10
2
+
3
+ - Adds method for reading complete member lists for rooms, improves the CS spec adherence
4
+ - Adds test for state events
5
+ - Fixes state event handler for rooms not actually passing events
6
+ - Fixes Api#new_for_domain using a faulty URI in certain cases
7
+
1
8
  ## 2.1.1 - 2020-08-21
2
9
 
3
10
  - Fixes crash if state event content is null (#11)
@@ -115,10 +115,10 @@ module MatrixSdk
115
115
  if target_uri.nil?
116
116
  # Attempt .well-known discovery for server-to-server
117
117
  well_known = begin
118
- uri = URI("https://#{domain}/.well-known/matrix/server")
119
- logger.debug "Trying #{uri}..."
120
- data = Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 5, read_timeout: 5, write_timeout: 5) do |http|
121
- http.get(uri.path).body
118
+ wk_uri = URI("https://#{domain}/.well-known/matrix/server")
119
+ logger.debug "Trying #{wk_uri}..."
120
+ data = Net::HTTP.start(wk_uri.host, wk_uri.port, use_ssl: true, open_timeout: 5, read_timeout: 5, write_timeout: 5) do |http|
121
+ http.get(wk_uri.path).body
122
122
  end
123
123
  JSON.parse(data)
124
124
  rescue StandardError => e
@@ -133,10 +133,10 @@ module MatrixSdk
133
133
  elsif %i[client identity].include? target
134
134
  # Attempt .well-known discovery
135
135
  well_known = begin
136
- uri = URI("https://#{domain}/.well-known/matrix/client")
137
- logger.debug "Trying #{uri}..."
138
- data = Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 5, read_timeout: 5, write_timeout: 5) do |http|
139
- http.get(uri.path).body
136
+ wk_uri = URI("https://#{domain}/.well-known/matrix/client")
137
+ logger.debug "Trying #{wk_uri}..."
138
+ data = Net::HTTP.start(wk_uri.host, wk_uri.port, use_ssl: true, open_timeout: 5, read_timeout: 5, write_timeout: 5) do |http|
139
+ http.get(wk_uri.path).body
140
140
  end
141
141
  data = JSON.parse(data)
142
142
  rescue StandardError => e
@@ -343,7 +343,7 @@ module MatrixSdk
343
343
 
344
344
  # Joins an already created room
345
345
  #
346
- # @param room_id_or_alias [String,MXID] A room alias (#room:exmaple.com) or a room ID (!id:example.com)
346
+ # @param room_id_or_alias [String,MXID] A room alias (#room:example.com) or a room ID (!id:example.com)
347
347
  # @param server_name [Array[String]] A list of servers to attempt the join through, required for IDs
348
348
  # @return [Room] The resulting room
349
349
  # @see Protocols::CS#join_room
@@ -561,6 +561,7 @@ module MatrixSdk
561
561
  return unless state_event.key? :type
562
562
 
563
563
  room = ensure_room(room_id)
564
+ room.send :put_state_event, state_event
564
565
  content = state_event[:content]
565
566
  case state_event[:type]
566
567
  when 'm.room.name'
@@ -617,7 +618,7 @@ module MatrixSdk
617
618
 
618
619
  join[:timeline][:events].each do |event|
619
620
  event[:room_id] = room_id.to_s
620
- handle_state(room_id, event) unless event[:type] == 'm.room.message'
621
+ handle_state(room_id, event) if event.key? :state_key
621
622
  room.send :put_event, event
622
623
 
623
624
  fire_event(MatrixEvent.new(self, event), event[:type])
@@ -1637,7 +1637,7 @@ module MatrixSdk::Protocols::CS
1637
1637
 
1638
1638
  room_id = ERB::Util.url_encode room_id.to_s
1639
1639
 
1640
- request(:get, :client_r0, "/rooms/#{room_id}/members", query: query)
1640
+ request(:get, :client_r0, "/rooms/#{room_id}/members", query: query.merge(params))
1641
1641
  end
1642
1642
 
1643
1643
  # Gets a list of the joined members in a room
@@ -157,6 +157,17 @@ module MatrixSdk
157
157
  members
158
158
  end
159
159
 
160
+ # Get all members (member events) in the room
161
+ #
162
+ # @note This will also count members who've knocked, been invited, have left, or have been banned.
163
+ #
164
+ # @param params [Hash] Additional query parameters to pass to the room member listing - e.g. for filtering purposes.
165
+ #
166
+ # @return [Array(User)] The complete list of members in the room, regardless of membership state
167
+ def all_members(**params)
168
+ client.api.get_room_members(id, **params)[:chunk].map { |ch| client.get_user(ch[:state_key]) }
169
+ end
170
+
160
171
  # Gets the current name of the room, querying the API if necessary
161
172
  #
162
173
  # @note Will cache the current name for 15 minutes
@@ -680,5 +691,9 @@ module MatrixSdk
680
691
  def put_ephemeral_event(event)
681
692
  fire_ephemeral_event MatrixEvent.new(self, event)
682
693
  end
694
+
695
+ def put_state_event(event)
696
+ fire_state_event MatrixEvent.new(self, event)
697
+ end
683
698
  end
684
699
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MatrixSdk
4
- VERSION = '2.1.1'
4
+ VERSION = '2.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matrix_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-21 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mocha