activematrix 0.0.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 +7 -0
- data/CHANGELOG.md +219 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/lib/matrix_sdk/api.rb +451 -0
- data/lib/matrix_sdk/bot/base.rb +847 -0
- data/lib/matrix_sdk/bot/main.rb +79 -0
- data/lib/matrix_sdk/bot.rb +4 -0
- data/lib/matrix_sdk/client.rb +696 -0
- data/lib/matrix_sdk/errors.rb +68 -0
- data/lib/matrix_sdk/mxid.rb +146 -0
- data/lib/matrix_sdk/protocols/as.rb +7 -0
- data/lib/matrix_sdk/protocols/cs.rb +1982 -0
- data/lib/matrix_sdk/protocols/is.rb +35 -0
- data/lib/matrix_sdk/protocols/msc.rb +152 -0
- data/lib/matrix_sdk/protocols/ss.rb +14 -0
- data/lib/matrix_sdk/response.rb +63 -0
- data/lib/matrix_sdk/room.rb +1044 -0
- data/lib/matrix_sdk/rooms/space.rb +79 -0
- data/lib/matrix_sdk/user.rb +168 -0
- data/lib/matrix_sdk/util/account_data_cache.rb +91 -0
- data/lib/matrix_sdk/util/events.rb +111 -0
- data/lib/matrix_sdk/util/extensions.rb +85 -0
- data/lib/matrix_sdk/util/state_event_cache.rb +92 -0
- data/lib/matrix_sdk/util/tinycache.rb +140 -0
- data/lib/matrix_sdk/util/tinycache_adapter.rb +87 -0
- data/lib/matrix_sdk/util/uri.rb +101 -0
- data/lib/matrix_sdk/version.rb +5 -0
- data/lib/matrix_sdk.rb +75 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d14da1f32ce2269f47a0e1124b264a0e2e61c3f19f94ad224b60951200ba55b
|
4
|
+
data.tar.gz: b12caea772bf4d1df1cbad903caaa888eff93c40dbcda081c53c89b598f69475
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f62a5e1eb8bd28688e2b9b029c156271f827ace85d6898ba75fb1b2d47c3185a7aaaadf8ed2a18ef1829ab4a1563a498715f1cbc188b2106f590eb8474b0fe3
|
7
|
+
data.tar.gz: fc32226c83adadca7cc70b4be9ca50e302e518185e26bd0dade5e91013ec582aaee9f8f40c601bd299384898686373f54da80868ab0a3ee6b805ee9210262947
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
## 2.8.0 - 2022-08-19
|
2
|
+
|
3
|
+
- Drops support for EoL Ruby 2.6
|
4
|
+
- Adds helpers for accessing room state
|
5
|
+
- Fixes Client#sync_token usage
|
6
|
+
- Improves caching of state events in rooms
|
7
|
+
|
8
|
+
## 2.7.0 - 2022-08-12
|
9
|
+
|
10
|
+
- Adds a bot subsystem + DSL
|
11
|
+
- [An example](examples/bot_api.rb) can be found in the examples folder
|
12
|
+
- Adds additional useful helpers for Room and User
|
13
|
+
- Fixes Client.new_for_domain
|
14
|
+
- Improves the handling of MXIDs as strings
|
15
|
+
- Improves handling of caches for rooms
|
16
|
+
- Improves Client shutdown when using Client#start_listener_thread
|
17
|
+
- Improves account data handling, with caches on both Client and Room level
|
18
|
+
|
19
|
+
## 2.6.0 - 2022-07-15
|
20
|
+
|
21
|
+
- Adds some multi-thread usage support to the API (create your API/client with `threadsafe: :multithread/true/false`)
|
22
|
+
The API will currently default to running with multi-threaded requests. In case your application is single-threaded - or never performs requests from multiple threads - then you can set `threadsafe: true/false` to support connection reuse.
|
23
|
+
- Changes room finding to ignore non-canonical aliases by default
|
24
|
+
- Improves room alias handling
|
25
|
+
- Improves Ruby 3.0+ support
|
26
|
+
- Improves debug output by supporting PP (Ruby pretty print) on all MatrixSdk objects
|
27
|
+
|
28
|
+
## 2.5.0 - 2022-01-14
|
29
|
+
|
30
|
+
- Adds preliminary support for the Matrix v1.1 `client/v3` API
|
31
|
+
- Adds some support for knocking rooms
|
32
|
+
- Adds mutex synchronization on API requests to avoid some threading issues
|
33
|
+
- Fixes error on attempting to skip cache for certain requests (#19)
|
34
|
+
- Fixes inconsistency in MXID typing for the Client abstraction (#18 #20)
|
35
|
+
- Fixes missed autoloader entries for errors (#22)
|
36
|
+
- Fixes some potential issues arising from broken user-provided state data
|
37
|
+
|
38
|
+
## 2.4.0 - 2021-07-19
|
39
|
+
|
40
|
+
- Adds support for matrix: URI's according to MSC2312
|
41
|
+
- Adds some basic support for detecting Spaces (MSC1772)
|
42
|
+
- Fixes sync against Synapse 1.38.0 missing empty fields
|
43
|
+
|
44
|
+
## 2.3.0 - 2021-03-26
|
45
|
+
|
46
|
+
- Adds support for Ruby 3.0 (#15)
|
47
|
+
- Adds support for requests against the Synapse admin API
|
48
|
+
- Adds helper methods for checking and changing user power levels
|
49
|
+
- Adds a proper caching system for room data
|
50
|
+
- Fixes argument error in `#get_room_messages`
|
51
|
+
- Removes unfinished and broken AS abstraction
|
52
|
+
|
53
|
+
## 2.2.0 - 2020-11-20
|
54
|
+
|
55
|
+
- Adds direct message (1:1) room mapping to client abstraction
|
56
|
+
- Adds Api#get_room_event_context (#13)
|
57
|
+
- Improves support for JRuby
|
58
|
+
|
59
|
+
## 2.1.3 - 2020-09-18
|
60
|
+
|
61
|
+
- Adds separate state event handler as Client#on_state_event
|
62
|
+
- Changes Client sync interval to by-default run at full speed
|
63
|
+
- Fixes state events being sent twice if included in both timeline and state of a sync
|
64
|
+
- Improves error reporting of broken 200 responses
|
65
|
+
- Improves event handlers for rooms, to not depend on a specific room object instance anymore
|
66
|
+
|
67
|
+
## 2.1.2 - 2020-09-10
|
68
|
+
|
69
|
+
- Adds method for reading complete member lists for rooms, improves the CS spec adherence
|
70
|
+
- Adds test for state events
|
71
|
+
- Fixes state event handler for rooms not actually passing events
|
72
|
+
- Fixes Api#new_for_domain using a faulty URI in certain cases
|
73
|
+
|
74
|
+
## 2.1.1 - 2020-08-21
|
75
|
+
|
76
|
+
- Fixes crash if state event content is null (#11)
|
77
|
+
- Fixes an uninitialized URI constant exception when requiring only the main library file
|
78
|
+
- Fixes the Api#get_pushrules method missing an ending slash in the request URI
|
79
|
+
- Fixes discovery code for client/server connections based on domain
|
80
|
+
|
81
|
+
## 2.1.0 - 2020-05-22
|
82
|
+
|
83
|
+
- Adds unique query IDs as well as duration in API debug output, to make it easier to track long requests
|
84
|
+
- Finishes up MSC support, get sync over SSE working flawlessly
|
85
|
+
- Exposes the #listen_forever method in the client abstraction
|
86
|
+
- Fixes room access methods
|
87
|
+
|
88
|
+
## 2.0.1 - 2020-03-13
|
89
|
+
|
90
|
+
- Adds code for handling non-final MSC's in protocols
|
91
|
+
- Currently implementing clients parts of MSC2018 for Sync over Server Sent Events
|
92
|
+
|
93
|
+
## 2.0.0 - 2020-02-14
|
94
|
+
|
95
|
+
**NB**, this release includes backwards-incompatible changes;
|
96
|
+
- Changes room state lookup to separate specific state lookups from full state retrieval.
|
97
|
+
This will require changes in client code where `#get_room_state` is called to retrieve
|
98
|
+
all state, as it now requires a state key. For retrieving full room state,
|
99
|
+
`#get_room_state_all` is now the method to use.
|
100
|
+
- Changes some advanced parameters to named parameters, ensure your code is updated if it makes use of them
|
101
|
+
- Fixes SSL verification to actually verify certs (#9)
|
102
|
+
|
103
|
+
- Adds multiple CS API endpoints
|
104
|
+
- Adds `:room_id` key to all room events
|
105
|
+
- Adds `:self` as a valid option to the client abstraction's `#get_user` method
|
106
|
+
- Separates homeserver part stringification for MXIDs
|
107
|
+
- Exposes some previously private client abstraction methods (`#ensure_room`, `#next_batch`) for easier bot usage
|
108
|
+
- Changes room abstraction member lookups to use `#get_room_joined_members`, reducing transferred data amounts
|
109
|
+
- Fixes debug print of methods that return arrays (e.g. CS `/room/{id}/state`)
|
110
|
+
|
111
|
+
## 1.5.0 - 2019-10-25
|
112
|
+
|
113
|
+
- Adds error event to the client abstraction, for handling errors in the background listener
|
114
|
+
- Adds an `open_timeout` setter to the API
|
115
|
+
- Fixes an overly aggressive filter for event handlers
|
116
|
+
|
117
|
+
## 1.4.0 - 2019-09-30
|
118
|
+
|
119
|
+
- Adds the option to change the logger globally or per-object.
|
120
|
+
|
121
|
+
## 1.3.0 - 2019-07-16
|
122
|
+
|
123
|
+
- Improves response handling to add accessors recursively
|
124
|
+
- Removes MatrixSdk extensions from the global scope,
|
125
|
+
if you've been using these in your own code you must now remember to
|
126
|
+
`extend MatrixSdk::Extensions` in order for them to be available.
|
127
|
+
|
128
|
+
## 1.2.1 - 2019-07-02
|
129
|
+
|
130
|
+
- Fixes mxc download URL generation
|
131
|
+
|
132
|
+
## 1.2.0 - 2019-06-28
|
133
|
+
|
134
|
+
- Adds getters and setters for more specced room state
|
135
|
+
- Fixes handling of the timeout parameter for the sync endpoint (#7)
|
136
|
+
- Additionally also now allows for running sync with a nil timeout
|
137
|
+
- Cleans up the CS protocol implementation slightly, removing a mutation that's not supposed to be there
|
138
|
+
- Cleans up the gemspec slightly, no longer uses `git ls-files`
|
139
|
+
- Add support for explicitly setting proxy config for API
|
140
|
+
|
141
|
+
## v1.1.1 - 2019-06-05
|
142
|
+
|
143
|
+
- Fixes a faulty include which broke the single implemented S2S endpoint
|
144
|
+
- Replaces the room name handling with a cached lazy loading system
|
145
|
+
|
146
|
+
## v1.1.0 - 2019-06-04
|
147
|
+
|
148
|
+
- The create_room method in the client abstraction now automatically stores the created room
|
149
|
+
- Adds more CS API endpoints, exposed as #get_joined_rooms, #get_public_rooms, and #username_available?
|
150
|
+
- Adds a method to the client abstraction to reload all joined rooms
|
151
|
+
- Adds a method to the client abstraction to get a list of all public rooms
|
152
|
+
- Adds avatar tracking to rooms in the client abstraction
|
153
|
+
- Adds lazy loading of join rules and guest access for rooms in the client abstraction
|
154
|
+
- Adds granular error classes like MatrixSdk::MatrixNotFoundError to make error handling easier
|
155
|
+
- Improves the CS API endpoint for room state retrieval
|
156
|
+
- Fixes an issue in the client abstraction where it would fail to load aliases if multiple HSes have applied aliases to a room
|
157
|
+
|
158
|
+
## v1.0.1 - 2019-05-24
|
159
|
+
|
160
|
+
- Fixes an error in the room creation code
|
161
|
+
- Fixes a divergence from spec in the room message request
|
162
|
+
- Fixes a slight divergence from spec in the kick method
|
163
|
+
- Fixes a divergence from spec in the tags handling methods
|
164
|
+
|
165
|
+
## v1.0.0 - 2019-05-17
|
166
|
+
|
167
|
+
- Improves testing and code coverage of existing code
|
168
|
+
- Fixes a series of minor bugs found during the writing of tests
|
169
|
+
|
170
|
+
## v0.1.0 - 2019-05-10
|
171
|
+
|
172
|
+
- Adds code for handling member lazy load in the client abstraction, and activates it by default
|
173
|
+
- Adds methods to read device keys from users
|
174
|
+
- Adds basic methods for device handling
|
175
|
+
- Restructures the API code to separate protocol implementations
|
176
|
+
- Improves the domain discovery code to support all currently specced methods
|
177
|
+
- Improves performance in sync calls
|
178
|
+
- Started work on an application service prototype, not ready for use yet
|
179
|
+
- Testing has been written for large parts of the code
|
180
|
+
|
181
|
+
## v0.0.4 - 2019-02-20
|
182
|
+
|
183
|
+
- Adds a parameter to the client abstraction to allow retrying syncs on timeouts
|
184
|
+
- Adds support for token-based login in the client abstraction
|
185
|
+
- Adds rudimentary username and password validation in the client abstraction
|
186
|
+
- Adds MXID validation in the client abstraction
|
187
|
+
- Adds a method to discover a homeserver address based on a domain.
|
188
|
+
- Supporting both SRV and .well-known lookups
|
189
|
+
- Adds methods from the r0.4.0 spec
|
190
|
+
- Adds support for version 3 event IDs
|
191
|
+
- Extends the connection exceptions with a specific timeout error
|
192
|
+
- Sets a series of filters in the simple client example to skip unhandled event
|
193
|
+
- Fixes an exception when null values end up in the body cleaner during debugging
|
194
|
+
- Fixes an error with CGI not being required correctly
|
195
|
+
|
196
|
+
## v0.0.3 - 2018-08-14
|
197
|
+
|
198
|
+
- Adds missing accessors for HTTP timeout
|
199
|
+
- Adds methods for checking auth status to client API
|
200
|
+
- Adds a wrapper class for API responses to ease use
|
201
|
+
- Adds option (and defaults) to store login details on registration
|
202
|
+
- Allows creating a MatrixSdk::Client off of an existing MatrixSdk::Api
|
203
|
+
- Extends event handling
|
204
|
+
|
205
|
+
- Fixes batch handling in sync
|
206
|
+
- Fixes event handling in the sample
|
207
|
+
- Removes unimplemented API methods to avoid confusion
|
208
|
+
|
209
|
+
- Plenty of documentation work
|
210
|
+
|
211
|
+
## v0.0.2 - 2018-05-11
|
212
|
+
|
213
|
+
- Fixes for multiple issues discovered after initial release
|
214
|
+
- Adds additional API methods
|
215
|
+
- Higher-level client API gets room and user abstractions
|
216
|
+
|
217
|
+
## v0.0.1 - 2018-05-06
|
218
|
+
|
219
|
+
Initial release
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Alexander "Ace" Olofsson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# ActiveMatrix
|
2
|
+
|
3
|
+
A Rails gem for integrating Matrix protocol communication into Ruby on Rails applications. This gem is a fork of the [matrix-sdk](https://github.com/ananace/ruby-matrix-sdk) gem, enhanced with Rails-specific features and tight integration with ActiveRecord and the Rails framework.
|
4
|
+
|
5
|
+
## About
|
6
|
+
|
7
|
+
ActiveMatrix provides a seamless way to add Matrix protocol support to your Rails applications, allowing you to build chat features, real-time messaging, and collaborative tools using the decentralized Matrix network.
|
8
|
+
|
9
|
+
## Example usage
|
10
|
+
|
11
|
+
For more fully-featured examples, check the [examples](examples/) folder.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# Raw API usage
|
15
|
+
require 'matrix_sdk'
|
16
|
+
|
17
|
+
api = MatrixSdk::Api.new 'https://matrix.org'
|
18
|
+
|
19
|
+
api.login user: 'example', password: 'notarealpass'
|
20
|
+
api.whoami?
|
21
|
+
# => {:user_id=>"@example:matrix.org"}
|
22
|
+
|
23
|
+
# It's possible to call arbitrary APIs as well
|
24
|
+
api.request :get, :federation_v1, '/version'
|
25
|
+
# => {:server=>{:version=>"0.28.1", :name=>"Synapse"}}
|
26
|
+
```
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# Client wrapper with login
|
30
|
+
require 'matrix_sdk'
|
31
|
+
|
32
|
+
client = MatrixSdk::Client.new 'https://example.com'
|
33
|
+
client.login 'username', 'notarealpass' #, no_sync: true
|
34
|
+
|
35
|
+
client.rooms.count
|
36
|
+
# => 5
|
37
|
+
hq = client.find_room '#matrix:matrix.org'
|
38
|
+
# => #<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>
|
39
|
+
hq.guest_access?
|
40
|
+
# => true
|
41
|
+
hq.send_text "This is an example message - don't actually do this ;)"
|
42
|
+
# => {:event_id=>"$123457890abcdef:matrix.org"}
|
43
|
+
```
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# Client wrapper with token
|
47
|
+
require 'matrix_sdk'
|
48
|
+
|
49
|
+
client = MatrixSdk::Client.new 'https://example.com'
|
50
|
+
client.api.access_token = 'thisisnotarealtoken'
|
51
|
+
|
52
|
+
# Doesn't automatically trigger a sync when setting the token directly
|
53
|
+
client.rooms.count
|
54
|
+
# => 0
|
55
|
+
|
56
|
+
client.sync
|
57
|
+
client.rooms.count
|
58
|
+
# => 5
|
59
|
+
```
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
#!/bin/env ruby
|
63
|
+
# Bot DSL
|
64
|
+
require 'matrix_sdk/bot'
|
65
|
+
|
66
|
+
command :plug do
|
67
|
+
room.send_text <<~PLUG
|
68
|
+
The Ruby SDK is a fine method for writing applications communicating over the Matrix protocol.
|
69
|
+
It can easily be integrated with Rails, and it supports most client/bot use-cases.
|
70
|
+
PLUG
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
## Contributing
|
75
|
+
|
76
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ananace/ruby-matrix-sdk
|
77
|
+
|
78
|
+
|
79
|
+
## License
|
80
|
+
|
81
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
82
|
+
|