matrix_sdk 1.1.0 → 1.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: 5b922104b5ab91c432c502117ed7f8f6a4c25121a8c407658427c28a9a9f47a3
4
- data.tar.gz: 99bc5b83c327b3ac326ce4515f77bd9801c260797036daaf2cb4192e08e74ec1
3
+ metadata.gz: 444586f27d6c0e30f71f5a9c064c0a3690ac692c819c477642fd143949d06c67
4
+ data.tar.gz: 5391c9869e9534f2e3fffd09313423c12228e90931d41d5e3724795b96ea4d20
5
5
  SHA512:
6
- metadata.gz: cd9020a5792c251aca178339ecd836495b07e414e7121711be4af78aef5fdd45d2c106fb59f9bead22767825dd694d0a43429c3db7c394bd90d9b48ddb9517c2
7
- data.tar.gz: d0a15efe764f0b6b9d0fd0ec11f50385da455a1fa3e3ad92f092cfd728f377726f3d84e4d961554519b724e6dc6e402113767050281e55bcee6e9328604091d2
6
+ metadata.gz: 641b169f971c77acc2123f3750f920aff520074972e5bf307706a0bd644eafd9415a4a7d2a9996f9389aed40683da823c26615b6766b0785fdaeec3c9686be71
7
+ data.tar.gz: 6c0486fab519db6bc9e33bd1f3826d49128d84974d463105d82370461fba2dba3e6aa44f9b2dc0b4662e8bb4d43106b9b10025833b3be860f68402dc32737bdb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.1.1 - 2019-06-05
2
+
3
+ - Fixes a faulty include which broke the single implemented S2S endpoint
4
+ - Replaces the room name handling with a cached lazy loading system
5
+
1
6
  ## v1.1.0 - 2019-06-04
2
7
 
3
8
  - The create_room method in the client abstraction now automatically stores the created room
@@ -13,7 +13,7 @@ module MatrixSdk
13
13
  include MatrixSdk::Protocols::AS
14
14
  include MatrixSdk::Protocols::CS
15
15
  include MatrixSdk::Protocols::IS
16
- include MatrixSdk::Protocols::CS
16
+ include MatrixSdk::Protocols::SS
17
17
 
18
18
  USER_AGENT = "Ruby Matrix SDK v#{MatrixSdk::VERSION}"
19
19
  DEFAULT_HEADERS = {
@@ -3,7 +3,7 @@
3
3
  module MatrixSdk::Protocols::SS
4
4
  # Gets the server version
5
5
  def server_version
6
- Response.new(self, request(:get, :federation_v1, '/version').server).tap do |resp|
6
+ MatrixSdk::Response.new(self, request(:get, :federation_v1, '/version').server).tap do |resp|
7
7
  resp.instance_eval <<-'CODE', __FILE__, __LINE__ + 1
8
8
  def to_s
9
9
  "#{name} #{version}"
@@ -39,7 +39,7 @@ module MatrixSdk
39
39
  # @return [Array(Object)] the last +event_history_limit+ events to arrive in the room
40
40
  # @see https://matrix.org/docs/spec/client_server/r0.3.0.html#get-matrix-client-r0-sync
41
41
  # The timeline events are what will end up in here
42
- attr_reader :id, :client, :name, :topic, :aliases, :members, :events
42
+ attr_reader :id, :client, :topic, :aliases, :members, :events
43
43
 
44
44
  # @!attribute [r] on_event
45
45
  # @return [EventHandlerArray] The list of event handlers for all events
@@ -81,6 +81,8 @@ module MatrixSdk
81
81
  instance_variable_set("@#{k}", v) if instance_variable_defined? "@#{k}"
82
82
  end
83
83
 
84
+ @name_checked = Time.new(0)
85
+
84
86
  logger.debug "Created room #{room_id}"
85
87
  end
86
88
 
@@ -125,6 +127,16 @@ module MatrixSdk
125
127
  members
126
128
  end
127
129
 
130
+ def name
131
+ return @name if Time.now - @name_checked < 10
132
+
133
+ @name_checked = Time.now
134
+ @name ||= client.api.get_room_name(id)
135
+ rescue MatrixNotFoundError
136
+ # No room name has been specified
137
+ nil
138
+ end
139
+
128
140
  # Gets the avatar url of the room - if any
129
141
  def avatar_url
130
142
  @avatar_url ||= client.api.get_room_state(id, 'm.room.avatar').url
@@ -410,12 +422,14 @@ module MatrixSdk
410
422
  # Reloads the name of the room
411
423
  # @return [Boolean] if the name was changed or not
412
424
  def reload_name!
413
- data = client.api.get_room_name(id)
414
- changed = data[:name] != name
425
+ data = begin
426
+ client.api.get_room_name(id)
427
+ rescue MatrixNotFoundError
428
+ nil
429
+ end
430
+ changed = data[:name] != @name
415
431
  @name = data[:name] if changed
416
432
  changed
417
- rescue MatrixNotFoundError
418
- nil
419
433
  end
420
434
  alias refresh_name! reload_name!
421
435
 
@@ -427,12 +441,14 @@ module MatrixSdk
427
441
  # Reloads the topic of the room
428
442
  # @return [Boolean] if the topic was changed or not
429
443
  def reload_topic!
430
- data = client.api.get_room_topic(id)
431
- changed = data[:topic] != topic
444
+ data = begin
445
+ client.api.get_room_topic(id)
446
+ rescue MatrixNotFoundError
447
+ nil
448
+ end
449
+ changed = data[:topic] != @topic
432
450
  @topic = data[:topic] if changed
433
451
  changed
434
- rescue MatrixNotFoundError
435
- nil
436
452
  end
437
453
  alias refresh_topic! reload_topic!
438
454
 
@@ -449,18 +465,21 @@ module MatrixSdk
449
465
  # @note The list of aliases is not sorted, ordering changes will result in
450
466
  # alias list updates.
451
467
  def reload_aliases!
452
- data = client.api.get_room_state(id)
453
- new_aliases = data.select { |chunk| chunk[:type] == 'm.room.aliases' && chunk.key?(:content) && chunk[:content].key?(:aliases) }
454
- .map { |chunk| chunk[:content][:aliases] }
455
- .flatten
456
- .compact
468
+ begin
469
+ new_aliases = client.api.get_room_state(id, 'm.room.aliases').aliases
470
+ rescue MatrixNotFoundError
471
+ data = client.api.get_room_state(id)
472
+ new_aliases = data.select { |chunk| chunk[:type] == 'm.room.aliases' && chunk.key?(:content) && chunk[:content].key?(:aliases) }
473
+ .map { |chunk| chunk[:content][:aliases] }
474
+ .flatten
475
+ .compact
476
+ end
477
+
457
478
  return false if new_aliases.nil?
458
479
 
459
480
  changed = new_aliases != aliases
460
481
  @aliases = new_aliases if changed
461
482
  changed
462
- rescue MatrixNotFoundError
463
- nil
464
483
  end
465
484
  alias refresh_aliases! reload_aliases!
466
485
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MatrixSdk
4
- VERSION = '1.1.0'
4
+ VERSION = '1.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: 1.1.0
4
+ version: 1.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: 2019-06-04 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.0.1
149
+ rubygems_version: 3.0.3
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: SDK for applications using the Matrix protocol