Code Monkey home page Code Monkey logo

ruby-matrix-sdk's Introduction

Ruby Matrix SDK

A Ruby gem for easing the development of software that communicates with servers implementing the Matrix protocol.

There is a Matrix room for the discussion about usage and development at #ruby-matrix-sdk:kittenface.studio.

Live YARD documentation can be found at; https://ruby-sdk.ananace.dev

Example usage

For more fully-featured examples, check the examples folder.

# Raw API usage
require 'matrix_sdk'

api = MatrixSdk::Api.new 'https://matrix.org'

api.login user: 'example', password: 'notarealpass'
api.whoami?
# => {:user_id=>"@example:matrix.org"}

# It's possible to call arbitrary APIs as well
api.request :get, :federation_v1, '/version'
# => {:server=>{:version=>"0.28.1", :name=>"Synapse"}}
# Client wrapper with login
require 'matrix_sdk'

client = MatrixSdk::Client.new 'https://example.com'
client.login 'username', 'notarealpass' #, no_sync: true

client.rooms.count
# => 5
hq = client.find_room '#matrix:matrix.org'
# => #<MatrixSdk::Room:00005592a1161528 @id="!cURbafjkfsMDVwdRDQ:matrix.org" @name="Matrix HQ" @topic="The Official Matrix HQ - please come chat here! | To support Matrix.org development: https://patreon.com/matrixdotorg | Try http://riot.im/app for a glossy web client | Looking for homeserver hosting? Check out https://upcloud.com/matrix!" @canonical_alias="#matrix:matrix.org" @aliases=["#matrix:jda.mn"] @join_rule=:public @guest_access=:can_join @event_history_limit=10>
hq.guest_access?
# => true
hq.send_text "This is an example message - don't actually do this ;)"
# => {:event_id=>"$123457890abcdef:matrix.org"}
# Client wrapper with token
require 'matrix_sdk'

client = MatrixSdk::Client.new 'https://example.com'
client.api.access_token = 'thisisnotarealtoken'

# Doesn't automatically trigger a sync when setting the token directly
client.rooms.count
# => 0

client.sync
client.rooms.count
# => 5
#!/bin/env ruby
# Bot DSL
require 'matrix_sdk/bot'

command :plug do
  room.send_text <<~PLUG
    The Ruby SDK is a fine method for writing applications communicating over the Matrix protocol.
    It can easily be integrated with Rails, and it supports most client/bot use-cases.
  PLUG
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ananace/ruby-matrix-sdk

License

The gem is available as open source under the terms of the MIT License.

ruby-matrix-sdk's People

Contributors

14mrh4x0r avatar ananace avatar ilvez avatar johannes-krude avatar kevinrademan avatar thestranjer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-matrix-sdk's Issues

`Client#sync` fails with `Net::ReadTimeout` on large timeout values

Client#sync takes a timeout parameter which is the amount of time to wait in case no new events are happening.

Net:HTTP#read_timeout is the amount of time until Net::ReadTimeout is raised in case the read syscall does not return. The default for this is 60 (seconds).

When calling Client#sync with a large timeout (e.g. 10 minutes), Net::ReadTimeout is raised before the server responds with an empty response.

As a workaround Client#sync can be called multiple times with a small timeout value.

Q: Invitations handling

Hi,
I played around a bit with your sdk (looking nice so far 😍) and was wondering if there is a way to handle invitations to rooms? I'm new to matrix so I don't know much yet, but to check invitations I had to get the sync data:

data = client.api.sync

which contained the invitations in invite_state hash. With this information it was possible to join the room via:

api.request(:post, :client_r0, '/join/!xxx:xxx.io')

Is there an easier/sdk way to get this? Didn't find any functions related to it.

Login always fails

First of all: I am a Ruby beginner (first day trying it) so it might be me being dumb.

When it tries to Login the Error is always:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:648:in `block in print_http': undefined method `replace' for nil:NilClass (NoMethodError)
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:648:in `each'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:648:in `print_http'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:613:in `block in request'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:610:in `loop'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:610:in `request'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:191:in `login'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/client.rb:87:in `login'
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:32:in `prepare_matrix'
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:10:in `initialize'
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:86:in `new'
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:86:in `<main>'

The code is:

hs_url = config['Matrix']['homeserver']
@client = MatrixSdk::Client.new hs_url
puts 'Logging in on Matrix...'
@client.login(config['mxid'], config['passwd'], no_sync: true)

This is in the above in the stacktrace named function prepare_matrix. The config fields all return strings. homeserver is present and filled with https://matrix.ffslfl.net (other config values are obviously private)

Occasional Net::HTTPBadResponse after sending first message

When sending a message with simple_client.rb sometimes it works fine, but other times I get these errors and the program exits after sending the message:

#<Thread:0x000055c9759eba80@/home/user/.gem/ruby/2.5.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:471 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        13: from /home/user/.gem/ruby/2.5.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
        12: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/client.rb:140:in `block in start_listener_thread'
        11: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/client.rb:162:in `listen_forever'
        10: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/client.rb:223:in `sync'
         9: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:126:in `sync'
         8: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:610:in `request'
         7: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:610:in `loop'
         6: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:614:in `block in request'
         5: from /usr/lib/ruby/2.5.0/net/http.rb:1464:in `request'
         4: from /usr/lib/ruby/2.5.0/net/http.rb:1491:in `transport_request'
         3: from /usr/lib/ruby/2.5.0/net/http.rb:1491:in `catch'
         2: from /usr/lib/ruby/2.5.0/net/http.rb:1494:in `block in transport_request'
         1: from /usr/lib/ruby/2.5.0/net/http/response.rb:29:in `read_new'
/usr/lib/ruby/2.5.0/net/http/response.rb:42:in `read_status_line': wrong status line: "0" (Net::HTTPBadResponse)
Traceback (most recent call last):
        14: from examples/simple_client.rb:78:in `<main>'
        13: from examples/simple_client.rb:78:in `loop'
        12: from examples/simple_client.rb:87:in `block in <main>'
        11: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/room.rb:140:in `send_text'
        10: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:289:in `send_message'
         9: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:241:in `send_message_event'
         8: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:610:in `request'
         7: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:610:in `loop'
         6: from /home/user/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:614:in `block in request'
         5: from /usr/lib/ruby/2.5.0/net/http.rb:1464:in `request'
         4: from /usr/lib/ruby/2.5.0/net/http.rb:1491:in `transport_request'
         3: from /usr/lib/ruby/2.5.0/net/http.rb:1491:in `catch'
         2: from /usr/lib/ruby/2.5.0/net/http.rb:1494:in `block in transport_request'
         1: from /usr/lib/ruby/2.5.0/net/http/response.rb:29:in `read_new'
/usr/lib/ruby/2.5.0/net/http/response.rb:42:in `read_status_line': wrong status line: "" (Net::HTTPBadResponse)

By running it a few times, I noticed that this either happens after the first message that is sent after the client is started or it doesn't happen at all. If it happens, it usually takes a few extra seconds to send the message, but it is delivered successfully just before exiting.

api.rb: uninitialized constant MatrixSdk::Api::CGI

When I try to send a message using the example client I get:

~/.gem/ruby/2.5.0/gems/matrix_sdk-0.0.3/lib/matrix_sdk/api.rb:237:in `send_message_event': uninitialized constant MatrixSdk::Api::CGI (NameError)

I thought that adding require 'cgi' in lib/matrix_sdk/api.rb should fix the problem, but it only worked if I added it in simple_client.rb as well 🤔.

Logger issue

I try to add it into a Rails project but I get an error:

client.login 'user', 'password'
NoMethodError: undefined method `[]' for #<ActiveSupport::Logger:0x00005626f02a1850>
from vendor/bundle/ruby/2.5.0/gems/matrix_sdk-1.2.1/lib/matrix_sdk/extensions.rb:76:in `logger'
Caused by NoMethodError: undefined method `[]' for #<ActiveSupport::Logger:0x00005626f02a1850>
from vendor/bundle/ruby/2.5.0/gems/matrix_sdk-1.2.1/lib/matrix_sdk/extensions.rb:76:in `logger'

Any suggestion on this on howto use the Rails logger?

`Api#login` access_token missmatches

Problem

The most prominently displayed example on how to use ruby-matrix-sdk does not work, since Api#login does not remember the access_token.

require 'matrix_sdk'
api = MatrixSdk::Api.new 'https://matrix.org'
api.login user: 'example', password: 'notarealpass'
api.whoami?
# => {:user_id=>"@example:matrix.org"}

Indeed, Client#login even contains a workaround for this problem by explicitly storing the access_token.

@api.access_token = data[:access_token]

The root cause of the problem is Api#login tries to store resp.token instead of resp.access_token. According to the spec, the correct key is access_token.

request(:post, client_api_latest, '/login', body: data, query: query).tap do |resp|
@access_token = resp.token if resp.key?(:token) && options[:store_token]

Possible Solutions

Change the example and remove the access token saving in Api#login

The example has not been working for several years and all users of Api#login are already forced to use some kind of workaround.
Insert the followoing into the example:

r = api.login user: 'example', password: 'notarealpass'
api.access_token = r[:access_token]

Fix Api#login and remove the workaround from Client#post_authentication

Fixing Api#login will not impact any code which includes workarounds as this code explicitly overwrites the saved access_token. Therefore, Api#login can safely be fixed and workaround can optionally be removed.

uninitialized class variable @@schemes in URI (NameError)

$irb
3.1.1 :001 > require 'matrix_sdk'
/home/bandura/.rvm/gems/ruby-3.1.1/gems/matrix_sdk-2.5.0/lib/matrix_sdk/util/uri.rb:15:in `<module:URI>': uninitialized class variable @@schemes in URI (NameError)
Did you mean?  scheme_list
	from /home/bandura/.rvm/gems/ruby-3.1.1/gems/matrix_sdk-2.5.0/lib/matrix_sdk/util/uri.rb:5:in `<top (required)>'
	from <internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /home/bandura/.rvm/gems/ruby-3.1.1/gems/matrix_sdk-2.5.0/lib/matrix_sdk.rb:4:in `<top (required)>'
	from <internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
	from <internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
	from <internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
	from (irb):1:in `<main>'
	from /home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
	from /home/bandura/.rvm/rubies/ruby-3.1.1/bin/irb:25:in `load'
	from /home/bandura/.rvm/rubies/ruby-3.1.1/bin/irb:25:in `<main>'
<internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- matrix_sdk (LoadError)
	from <internal:/home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from (irb):1:in `<main>'
	from /home/bandura/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
	from /home/bandura/.rvm/rubies/ruby-3.1.1/bin/irb:25:in `load'
	from /home/bandura/.rvm/rubies/ruby-3.1.1/bin/irb:25:in `<main>'

$ruby -v        
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux]

installed ruby via rvm

Expand bot DSL language

The current DSL is slightly limited, only supporting single-word commands, and with very limited support for optionals and the like.

It might be interesting to build something based on Thor's design, or at least design something with sub-commands. E.g. !command subcommand [ARGS...]

Support for end-to-end encryption / olm library integration?

Hi! Thanks for this project, it's very useful.

Do you have any interest in using this Ruby olm library in order to implement e2e encryption? As it currently stands, I'm able to use this library pretty well, although the client shows up as unencrypted within encrypted rooms. The olm library is pretty old but seems to be explicitly focused on supporting Matrix's use of the algorithm.

Can't destroy an unused room?

I have a room which I can find by client.find_room(id). I left the room via the Riot desktop interface. Now a room.leave results in

MatrixSdk::MatrixNotFoundError: Not a known room

however room.members returns my one user (details removed)

[0] #<MatrixSdk::User:0x00007fd2a7af6ac8 @id="@user:my.homeserver.com" @display_name="user" @avatar_url=nil}>

api.forget_room(room.id) responds with an unrecognized access token. Passing the access token as a parameter doesn't help.

Initially, I set an alias for the room. Trying to reuse the alias called the issue to my attention.
api.get_room_id("#user_reminders:my.homeserver.com") properly returns the room id and the server.

I feel I'm missing something. Any ideas?

Inverted logic for SSL

I found a piece of the api where the wording doesnt really make sense

# Check for validd ssl certificates
MatrixSdk::Client.new(url, validate_certificate: false)

# Ignore invalid ssl certificates
MatrixSdk::Client.new(url, validate_certificate: true)

Perhaps this flag should be changed to disable_validate_certificate?

FYI: Code at the heart of this issue

@http.verify_mode = validate_certificate ? ::OpenSSL::SSL::VERIFY_NONE : nil

Net::OpenTimeout: execution expired

<#<Net::OpenTimeout: execution expired>

/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/net/http.rb:987:in `initialize'
/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/net/http.rb:987:in `open'
/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/net/http.rb:987:in `block in connect'
/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/timeout.rb:107:in `timeout'
/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/net/http.rb:985:in `connect'
/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/net/http.rb:970:in `do_start'
/opt/zammad/vendor/ruby-3.0.4/lib/ruby/3.0.0/net/http.rb:965:in `start'
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/matrix_sdk-2.8.0/lib/matrix_sdk/api.rb:441:in `http'
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/matrix_sdk-2.8.0/lib/matrix_sdk/api.rb:303:in `block in request'
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/matrix_sdk-2.8.0/lib/matrix_sdk/api.rb:294:in `loop'
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/matrix_sdk-2.8.0/lib/matrix_sdk/api.rb:294:in `request'
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/matrix_sdk-2.8.0/lib/matrix_sdk/protocols/cs.rb:1446:in `get_avatar_url'
/opt/zammad/vendor/bundle/ruby/3.0.0/gems/matrix_sdk-2.8.0/lib/matrix_sdk/user.rb:60:in `avatar_url'

If your bot is requesting a lot you will easily get into this error. It can be solved by increasing the rate limit:

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#override-ratelimiting-for-users

Alternatively this is also possible via SQL:

matrix-org/synapse#6286 (comment)

EDIT 1

I still have the issue. The changes did not work. I asked in the synapse chat and they adviced me to search in the reverse proxies. I will keep this post up to date when I find new ideas to solve the issue.

image

`Client#mxid` returns String instead of MXID after `Client#login`

According to the docs, Client#mxid should return an MXID.

When using Client#login, @mxid is assigned a String in Client#post_authenticate.

require "matrix_sdk"

client = MatrixSdk::Client.new("https://server")
begin
	client.login("user", "password")
	puts client.mxid.class
ensure
	client.logout
end

Results in String.

Arity Error on MatrixSdk::Client.new - ArgumentError (wrong number of arguments (given 2, expected 1))

MatrixSdk::Client.new("https://some.server.org",:all,{:user_id => "someuser"})
Traceback (most recent call last):
7: from /usr/bin/irb:13:in <main>' 6: from org/jruby/RubyKernel.java:1189:in catch'
5: from org/jruby/RubyKernel.java:1189:in catch' 4: from org/jruby/RubyKernel.java:1442:in loop'
3: from org/jruby/RubyKernel.java:1048:in eval' 2: from (irb):3:in evaluate'
1: from /opt/jruby/lib/ruby/gems/shared/gems/matrix_sdk-2.1.3/lib/matrix_sdk/client.rb:3:in `initialize'
ArgumentError (wrong number of arguments (given 2, expected 1))

`Util::Tinycache` `unless:` argument missmatch

In lib/matrix_sdk/util/tinycache.rb:103, the proc is called with three arguments

unless_proc&.call(self, method_name, args)

, but the proc created in vi lib/matrix_sdk/room.rb:36, only takes a single argument

unless: proc { |args| args.any? }

When calling Room#all_members, this results in:

	1: from .../.gem/ruby/2.7.0/gems/matrix_sdk-2.4.0/lib/matrix_sdk/util/tinycache.rb:103:in `block (2 levels) in build_cache_methods'
.../.gem/ruby/2.7.0/gems/matrix_sdk-2.4.0/lib/matrix_sdk/room.rb:36:in `block in <class:Room>': undefined method `any?' for #<MatrixSdk::Room:0x0000564f3dd6a780> (NoMethodError)

Possible solutions may be:

  • Adding more arguments in room.rb
  • Removing arguments in tinycache.rb
  • Asking Proc#arity for the number of required arguments

m.room.aliases is deprecated since MSC2432

It seems the spec has evolved since Room#aliases was implemented.

m.room.aliases is deprecated and I have a room which an uptodate m.room.canonical_alias as well as an old m.room.aliases state event which contains outdated aliases.

Upon initical sync, matrix-ruby-sdk uses the m.room.canonical_aliases state, but after one hour the cache is discarded and ruby-matrix-sdk then instead uses m.room.aliases in Room#aliases and Protocols::CS#get_room_aliases.

There are now two different sources to get aliases from:

In my opinion, any handling of m.room.aliases should be removed from ruby-matrix-sdk.

Crashes if initial sync fails because of a timeout

Hi back with another error :)

DEBUG  MatrixSdk::Api : >
C:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/ruby-matrix-sdk-c5a1c98661c9/lib/matrix_sdk/api.rb:628:in `block in request': #<Net::HTTPGatewayTimeOut:0x0000000004202570> (MatrixSdk::MatrixConnectionError)
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/ruby-matrix-sdk-c5a1c98661c9/lib/matrix_sdk/api.rb:610:in `loop'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/ruby-matrix-sdk-c5a1c98661c9/lib/matrix_sdk/api.rb:610:in `request'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/ruby-matrix-sdk-c5a1c98661c9/lib/matrix_sdk/api.rb:126:in `sync'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/ruby-matrix-sdk-c5a1c98661c9/lib/matrix_sdk/client.rb:248:in `sync'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/bundler/gems/ruby-matrix-sdk-c5a1c98661c9/lib/matrix_sdk/client.rb:102:in `login'
DEBUG  MatrixSdk::Api : < Received a 504 Gateway Time-out response:
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:31:in `prepare_matrix'
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:10:in `initialize'
DEBUG  MatrixSdk::Api : < server: nginx/1.13.3
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:92:in `new'
DEBUG  MatrixSdk::Api : < date: Mon, 20 Aug 2018 11:53:22 GMT
        from C:/Users/marce/RubymineProjects/node_alert/main.rb:92:in `<main>'
DEBUG  MatrixSdk::Api : < content-type: text/html
DEBUG  MatrixSdk::Api : < content-length: 183
DEBUG  MatrixSdk::Api : < connection: keep-alive
DEBUG  MatrixSdk::Api : <

seems like it crashes if gateway timeout happens on initial sync

Handling non spec-conformant events

I managed to accidentally set the join_rule in a room to nil

{
  "content": {
    "join_rule": null
  },
  ...
  "type": "m.room.join_rules",
  ...
}

This now causes an exception in Client#login

.gem/ruby/2.7.0/gems/matrix_sdk-2.4.0.1/lib/matrix_sdk/room.rb:886:in `handle_room_join_rules': undefined method `to_sym' for nil:NilClass (NoMethodError)

ruby-matrix-sdk will crash for any user which is joined to that room. Although a nil join_rule is non spec-compliant, nothing prevents anybody from generating non spec-compliant events.

Element-desktop handles this much better and does not crash.

I would prefer, if ruby-matrix-sdk can not be crashed by anybody who shares a room with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.