matrix_sdk 2.1.0 → 2.1.1

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: 88e56c3775bf881fb720e4e262ff6073136204d26b72c03bb1bbd2a4138b90ee
4
- data.tar.gz: c8f5223c4c0c4febda391e8320a90667b6438b92806ce0b9b7c251a506678730
3
+ metadata.gz: 487904c24bd70f3d0412ba040f84687d6ef7a6bfe570d259f6d5d73fe7194128
4
+ data.tar.gz: 7d6f53ba5ec1e1426c5bd274e0809f0edcb67a8e8a355b1dd6d409ac57ee3e0f
5
5
  SHA512:
6
- metadata.gz: 7ce44dc75ea446ff9f901d8309f58df4251c2c199540d27f086fbb77359974b5950da8c960540e3d7e89d1a40b7f264dfb9f1c5ad8462c4e94176fcb19fedc60
7
- data.tar.gz: 0b2acb16c36524bac00528fe322984a587f8f0c951754d316148fbd337a5f0dafec6ce5daf3cdc5829673115bb96453b60475702633ca1e11718d5e78c8e37b0
6
+ metadata.gz: cfbaff099abec9777a5593fa1646ff5e4285fc246894f850b000834185d352f024e8bc9340c17554da6e73c056db9f327bd98f27c259d123ceadf78977203ed0
7
+ data.tar.gz: f53ec1ca41f8884a8916609f364db9fd849b8957629c1f46cfaa440910030035d6f4c92de464aaabd3dc3d207ccf47e9bedccce30980ab213a625d5bb4e13473
@@ -1,3 +1,10 @@
1
+ ## 2.1.1 - 2020-08-21
2
+
3
+ - Fixes crash if state event content is null (#11)
4
+ - Fixes an uninitialized URI constant exception when requiring only the main library file
5
+ - Fixes the Api#get_pushrules method missing an ending slash in the request URI
6
+ - Fixes discovery code for client/server connections based on domain
7
+
1
8
  ## 2.1.0 - 2020-05-22
2
9
 
3
10
  - Adds unique query IDs as well as duration in API debug output, to make it easier to track long requests
@@ -92,6 +92,8 @@ module MatrixSdk
92
92
  uri = URI("http#{ssl ? 's' : ''}://#{domain}")
93
93
  well_known = nil
94
94
  target_uri = nil
95
+ logger = ::Logging.logger[self]
96
+ logger.debug "Resolving #{domain}"
95
97
 
96
98
  if !port.nil? && !port.empty?
97
99
  # If the domain is fully qualified according to Matrix (FQDN and port) then skip discovery
@@ -101,17 +103,26 @@ module MatrixSdk
101
103
  target_uri = begin
102
104
  require 'resolv'
103
105
  resolver = Resolv::DNS.new
104
- resolver.getresource("_matrix._tcp.#{domain}")
105
- rescue StandardError
106
+ srv = "_matrix._tcp.#{domain}"
107
+ logger.debug "Trying DNS #{srv}..."
108
+ d = resolver.getresource(srv, Resolv::DNS::Resource::IN::SRV)
109
+ d
110
+ rescue StandardError => e
111
+ logger.debug "DNS lookup failed with #{e.class}: #{e.message}"
106
112
  nil
107
113
  end
108
114
 
109
115
  if target_uri.nil?
110
116
  # Attempt .well-known discovery for server-to-server
111
117
  well_known = begin
112
- data = Net::HTTP.get("https://#{domain}/.well-known/matrix/server")
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
122
+ end
113
123
  JSON.parse(data)
114
- rescue StandardError
124
+ rescue StandardError => e
125
+ logger.debug "Well-known failed with #{e.class}: #{e.message}"
115
126
  nil
116
127
  end
117
128
 
@@ -122,9 +133,14 @@ module MatrixSdk
122
133
  elsif %i[client identity].include? target
123
134
  # Attempt .well-known discovery
124
135
  well_known = begin
125
- data = Net::HTTP.get("https://#{domain}/.well-known/matrix/client")
126
- JSON.parse(data)
127
- rescue StandardError
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
140
+ end
141
+ data = JSON.parse(data)
142
+ rescue StandardError => e
143
+ logger.debug "Well-known failed with #{e.class}: #{e.message}"
128
144
  nil
129
145
  end
130
146
 
@@ -138,6 +154,7 @@ module MatrixSdk
138
154
  end
139
155
  end
140
156
  end
157
+ logger.debug "Using #{target_uri.inspect}"
141
158
 
142
159
  # Fall back to direct domain connection
143
160
  target_uri ||= URI("https://#{domain}:8448")
@@ -44,7 +44,7 @@ module MatrixSdk
44
44
  # @see #initialize
45
45
  def self.new_for_domain(domain, **params)
46
46
  api = MatrixSdk::Api.new_for_domain(domain, keep_wellknown: true)
47
- return new(api, params) unless api.well_known.key? 'm.identity_server'
47
+ return new(api, params) unless api.well_known&.key?('m.identity_server')
48
48
 
49
49
  identity_server = MatrixSdk::Api.new(api.well_known['m.identity_server']['base_url'], protocols: %i[IS])
50
50
  new(api, params.merge(identity_server: identity_server))
@@ -574,9 +574,9 @@ module MatrixSdk
574
574
  when 'm.room.aliases'
575
575
  room.instance_variable_get('@aliases').concat content[:aliases]
576
576
  when 'm.room.join_rules'
577
- room.instance_variable_set '@join_rule', content[:join_rule].to_sym
577
+ room.instance_variable_set '@join_rule', content[:join_rule].nil? ? nil : content[:join_rule].to_sym
578
578
  when 'm.room.guest_access'
579
- room.instance_variable_set '@guest_access', content[:guest_access].to_sym
579
+ room.instance_variable_set '@guest_access', content[:guest_access].nil? ? nil : content[:guest_access].to_sym
580
580
  when 'm.room.member'
581
581
  return unless cache == :all
582
582
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'uri'
4
+
3
5
  module URI
4
6
  # A mxc:// Matrix content URL
5
7
  class MATRIX < Generic
@@ -1823,7 +1823,7 @@ module MatrixSdk::Protocols::CS
1823
1823
  # @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushrules
1824
1824
  # The Matrix Spec, for more information about the parameters and data
1825
1825
  def get_pushrules
1826
- request(:get, :client_r0, '/pushrules')
1826
+ request(:get, :client_r0, '/pushrules/')
1827
1827
  end
1828
1828
 
1829
1829
  # Retrieves a single registered push rule for the current user
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MatrixSdk
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.1'
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.0
4
+ version: 2.1.1
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-05-22 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mocha