matrix_sdk 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/matrix_sdk.rb +2 -2
- data/lib/matrix_sdk/api.rb +11 -1
- data/lib/matrix_sdk/client.rb +10 -1
- data/lib/matrix_sdk/extensions.rb +14 -1
- data/lib/matrix_sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3aa6522f1b8b49ed1ea60dc27c67fefb9479b5aa27d87c4597edf97e76d4eb6
|
4
|
+
data.tar.gz: b2a6d3b5ff58c037092515ccf42e0a2683f1ef024a8b6731c824faade7649a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b55690dbf6fe96eeb24a6831d390e122962b1c68d5e0031deb32641eaeb7f38568d47ec728d0adbd4eb9aea5d1f2064ff926667588b9b77893314b999366245b
|
7
|
+
data.tar.gz: 73eb136cd9285ffc1415b79c25ac05807eb0b17f52865df329ebff1a83962a5005802a3f914b7ebfe8f6a2371097967955dcdcd6de01d4148c5fd9d3c96dafbd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 1.5.0 - 2019-10-25
|
2
|
+
|
3
|
+
- Adds error event to the client abstraction, for handling errors in the background listener
|
4
|
+
- Adds an `open_timeout` setter to the API
|
5
|
+
- Fixes an overly aggressive filter for event handlers
|
6
|
+
|
1
7
|
## 1.4.0 - 2019-09-30
|
2
8
|
|
3
9
|
- Adds the option to change the logger globally or per-object.
|
data/lib/matrix_sdk.rb
CHANGED
@@ -42,10 +42,10 @@ module MatrixSdk
|
|
42
42
|
|
43
43
|
def self.logger=(global_logger)
|
44
44
|
@logger = global_logger
|
45
|
-
@
|
45
|
+
@global_logger = !global_logger.nil?
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.global_logger?
|
49
|
-
@
|
49
|
+
@global_logger ||= false
|
50
50
|
end
|
51
51
|
end
|
data/lib/matrix_sdk/api.rb
CHANGED
@@ -23,7 +23,7 @@ module MatrixSdk
|
|
23
23
|
}.freeze
|
24
24
|
|
25
25
|
attr_accessor :access_token, :connection_address, :connection_port, :device_id, :autoretry, :global_headers
|
26
|
-
attr_reader :homeserver, :validate_certificate, :read_timeout, :protocols, :well_known, :proxy_uri
|
26
|
+
attr_reader :homeserver, :validate_certificate, :open_timeout, :read_timeout, :protocols, :well_known, :proxy_uri
|
27
27
|
|
28
28
|
ignore_inspect :access_token, :logger
|
29
29
|
|
@@ -38,6 +38,7 @@ module MatrixSdk
|
|
38
38
|
# @option params [Boolean] :validate_certificate (false) Should the connection require valid SSL certificates
|
39
39
|
# @option params [Integer] :transaction_id (0) The starting ID for transactions
|
40
40
|
# @option params [Numeric] :backoff_time (5000) The request backoff time in milliseconds
|
41
|
+
# @option params [Numeric] :open_timeout (60) The timeout in seconds to wait for a TCP session to open
|
41
42
|
# @option params [Numeric] :read_timeout (240) The timeout in seconds for reading responses
|
42
43
|
# @option params [Hash] :global_headers Additional headers to set for all requests
|
43
44
|
# @option params [Boolean] :skip_login Should the API skip logging in if the HS URL contains user information
|
@@ -63,6 +64,7 @@ module MatrixSdk
|
|
63
64
|
@validate_certificate = params.fetch(:validate_certificate, false)
|
64
65
|
@transaction_id = params.fetch(:transaction_id, 0)
|
65
66
|
@backoff_time = params.fetch(:backoff_time, 5000)
|
67
|
+
@open_timeout = params.fetch(:open_timeout, 60)
|
66
68
|
@read_timeout = params.fetch(:read_timeout, 240)
|
67
69
|
@well_known = params.fetch(:well_known, {})
|
68
70
|
@global_headers = DEFAULT_HEADERS.dup
|
@@ -155,6 +157,13 @@ module MatrixSdk
|
|
155
157
|
protocols.include? protocol
|
156
158
|
end
|
157
159
|
|
160
|
+
# @param seconds [Numeric]
|
161
|
+
# @return [Numeric]
|
162
|
+
def open_timeout=(seconds)
|
163
|
+
@http.finish if @http && @open_timeout != seconds
|
164
|
+
@open_timeout = seconds
|
165
|
+
end
|
166
|
+
|
158
167
|
# @param seconds [Numeric]
|
159
168
|
# @return [Numeric]
|
160
169
|
def read_timeout=(seconds)
|
@@ -291,6 +300,7 @@ module MatrixSdk
|
|
291
300
|
Net::HTTP.new(host, port)
|
292
301
|
end
|
293
302
|
|
303
|
+
@http.open_timeout = open_timeout
|
294
304
|
@http.read_timeout = read_timeout
|
295
305
|
@http.use_ssl = homeserver.scheme == 'https'
|
296
306
|
@http.verify_mode = validate_certificate ? ::OpenSSL::SSL::VERIFY_NONE : nil
|
data/lib/matrix_sdk/client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'matrix_sdk'
|
4
4
|
|
5
|
+
require 'English'
|
5
6
|
require 'forwardable'
|
6
7
|
|
7
8
|
module MatrixSdk
|
@@ -13,7 +14,7 @@ module MatrixSdk
|
|
13
14
|
attr_reader :api
|
14
15
|
attr_accessor :cache, :sync_filter
|
15
16
|
|
16
|
-
events :event, :presence_event, :invite_event, :leave_event, :ephemeral_event
|
17
|
+
events :error, :event, :presence_event, :invite_event, :leave_event, :ephemeral_event
|
17
18
|
ignore_inspect :api,
|
18
19
|
:on_event, :on_presence_event, :on_invite_event, :on_leave_event, :on_ephemeral_event
|
19
20
|
|
@@ -257,6 +258,10 @@ module MatrixSdk
|
|
257
258
|
@sync_thread = nil
|
258
259
|
end
|
259
260
|
|
261
|
+
def listening?
|
262
|
+
@sync_thread&.alive? == true
|
263
|
+
end
|
264
|
+
|
260
265
|
def sync(skip_store_batch: false, **params)
|
261
266
|
extra_params = {
|
262
267
|
filter: sync_filter,
|
@@ -301,6 +306,10 @@ module MatrixSdk
|
|
301
306
|
end
|
302
307
|
end
|
303
308
|
end
|
309
|
+
rescue StandardError => e
|
310
|
+
logger.error "Unhandled #{e.class} raised in background listener"
|
311
|
+
logger.error [e.message, *e.backtrace].join($RS)
|
312
|
+
fire_error(ErrorEvent.new(e, :listener_thread))
|
304
313
|
end
|
305
314
|
|
306
315
|
def post_authentication(data)
|
@@ -107,7 +107,7 @@ module MatrixSdk
|
|
107
107
|
def fire(event, filter = nil)
|
108
108
|
reverse_each do |_k, h|
|
109
109
|
begin
|
110
|
-
h[:block].call(event) if event.matches?(h[:filter], filter)
|
110
|
+
h[:block].call(event) if !h[:filter] || event.matches?(h[:filter], filter)
|
111
111
|
rescue StandardError => e
|
112
112
|
logger.error "#{e.class.name} occurred when firing event (#{event})\n#{e}"
|
113
113
|
|
@@ -138,6 +138,19 @@ module MatrixSdk
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
class ErrorEvent < Event
|
142
|
+
attr_accessor :error
|
143
|
+
|
144
|
+
def initialize(error, source)
|
145
|
+
@error = error
|
146
|
+
super source
|
147
|
+
end
|
148
|
+
|
149
|
+
def source
|
150
|
+
@sender
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
141
154
|
class MatrixEvent < Event
|
142
155
|
attr_accessor :event, :filter
|
143
156
|
|
data/lib/matrix_sdk/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Olofsson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mocha
|