async-matrix 1.2.1 → 2.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 +4 -4
- data/lib/async/discord/api/path_tree.rb +2 -5
- data/lib/async/discord/api.rb +1 -6
- data/lib/async/discord/client.rb +1 -4
- data/lib/async/discord/error.rb +1 -5
- data/lib/async/discord/gateway.rb +1 -4
- data/lib/async/discord.rb +0 -1
- data/lib/async/matrix/api/chain.rb +1 -4
- data/lib/async/matrix/api/concat.rb +1 -5
- data/lib/async/matrix/api/path_tree.rb +1 -4
- data/lib/async/matrix/api.rb +1 -5
- data/lib/async/matrix/application_service/bot.rb +4 -7
- data/lib/async/matrix/application_service/config/vivify.rb +1 -5
- data/lib/async/matrix/application_service/config.rb +1 -4
- data/lib/async/matrix/application_service/dispatcher.rb +65 -9
- data/lib/async/matrix/application_service/error_response.rb +1 -5
- data/lib/async/matrix/application_service/event.rb +1 -5
- data/lib/async/matrix/application_service/server.rb +339 -211
- data/lib/async/matrix/application_service/transaction.rb +1 -5
- data/lib/async/matrix/application_service/transaction_handler.rb +185 -0
- data/lib/async/matrix/application_service/transaction_store.rb +1 -5
- data/lib/async/matrix/bridge/discord/db/connection.rb +1 -3
- data/lib/async/matrix/bridge/discord/db/file.rb +2 -4
- data/lib/async/matrix/bridge/discord/db/guild.rb +2 -4
- data/lib/async/matrix/bridge/discord/db/message.rb +2 -4
- data/lib/async/matrix/bridge/discord/db/portal.rb +2 -4
- data/lib/async/matrix/bridge/discord/db/puppet.rb +2 -4
- data/lib/async/matrix/bridge/discord/db/reaction.rb +2 -4
- data/lib/async/matrix/bridge/discord/db/schema.rb +18 -0
- data/lib/async/matrix/bridge/discord/db/user.rb +2 -4
- data/lib/async/matrix/bridge/discord/db.rb +14 -16
- data/lib/async/matrix/client.rb +1 -4
- data/lib/async/matrix/connection.rb +1 -4
- data/lib/async/matrix/double_puppet_client.rb +2 -4
- data/lib/async/matrix/e2ee.rb +1 -2
- data/lib/async/matrix/endpoint.rb +1 -4
- data/lib/async/matrix/error.rb +1 -4
- data/lib/async/matrix/media_client.rb +1 -4
- data/lib/async/matrix/notifier.rb +1 -4
- data/lib/async/matrix/schema/registry.rb +1 -2
- data/lib/async/matrix/schema/validation_error.rb +1 -2
- data/lib/async/matrix/schema.rb +1 -5
- data/lib/async/matrix/server.rb +1 -4
- data/lib/async/matrix/stream.rb +1 -4
- data/lib/async/matrix/version.rb +1 -1
- data/lib/async/matrix.rb +4 -1
- metadata +23 -7
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
|
-
require "async/matrix"
|
|
8
|
-
|
|
9
6
|
module Async
|
|
10
7
|
module Matrix
|
|
11
8
|
module ApplicationService
|
|
@@ -21,7 +18,7 @@ module Async
|
|
|
21
18
|
end
|
|
22
19
|
end
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
__END__
|
|
25
22
|
describe "Async::Matrix::ApplicationService::Transaction" do
|
|
26
23
|
it "wraps events array" do
|
|
27
24
|
txn = Async::Matrix::ApplicationService::Transaction.new({
|
|
@@ -67,4 +64,3 @@ test do
|
|
|
67
64
|
txn.ephemeral.should.be.empty
|
|
68
65
|
end
|
|
69
66
|
end
|
|
70
|
-
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the Apache License, Version 2.0.
|
|
4
|
+
# Copyright, 2026, by General Intelligence Systems.
|
|
5
|
+
|
|
6
|
+
require "console"
|
|
7
|
+
|
|
8
|
+
module Async
|
|
9
|
+
module Matrix
|
|
10
|
+
module ApplicationService
|
|
11
|
+
# Routes incoming Matrix events to registered handler objects.
|
|
12
|
+
#
|
|
13
|
+
# Each handler declares the event types it handles via `#event_types`.
|
|
14
|
+
# When an event arrives, the transaction_handler finds all matching handlers
|
|
15
|
+
# and calls them. Errors in one handler do not prevent others from running.
|
|
16
|
+
class TransactionHandler
|
|
17
|
+
def initialize(txn_store: TransactionStore.new)
|
|
18
|
+
@handlers = Hash.new { |h, k| h[k] = [] }
|
|
19
|
+
@txn_store = txn_store
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Register a Bot (responds to #handlers) or a plain handler (responds
|
|
23
|
+
# to #event_types and #call). Bots are expanded into their handlers.
|
|
24
|
+
def register(handler)
|
|
25
|
+
if handler.respond_to?(:handlers)
|
|
26
|
+
handler.handlers.each { |h| register(h) }
|
|
27
|
+
else
|
|
28
|
+
handler.event_types.each do |type|
|
|
29
|
+
@handlers[type] << handler
|
|
30
|
+
Console.info(self) { "Registered #{handler.class.name} for #{type}" }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Idempotently process a homeserver transaction. Duplicate transaction
|
|
36
|
+
# IDs (already seen) are skipped. Returns :processed or :duplicate.
|
|
37
|
+
#
|
|
38
|
+
# The idempotency store lives here rather than in the HTTP layer because
|
|
39
|
+
# the Grape server is stateless across requests — the transaction_handler is the
|
|
40
|
+
# stable, long-lived object.
|
|
41
|
+
def receive_transaction(txn_id, body)
|
|
42
|
+
if @txn_store.seen?(txn_id)
|
|
43
|
+
Console.debug(self) { "Duplicate transaction #{txn_id} — skipping" }
|
|
44
|
+
:duplicate
|
|
45
|
+
else
|
|
46
|
+
dispatch_transaction(body)
|
|
47
|
+
@txn_store.mark_seen(txn_id)
|
|
48
|
+
:processed
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def dispatch_transaction(body)
|
|
53
|
+
Transaction.new(body).then do |txn|
|
|
54
|
+
txn.events.each { |event| dispatch(event) }
|
|
55
|
+
txn.ephemeral.each { |event| dispatch(event) }
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def dispatch(event)
|
|
60
|
+
type = event.type
|
|
61
|
+
handlers = @handlers[type]
|
|
62
|
+
|
|
63
|
+
if handlers.empty?
|
|
64
|
+
Console.debug(self) { "No handler for event type: #{type}" }
|
|
65
|
+
else
|
|
66
|
+
handlers.each do |handler|
|
|
67
|
+
begin
|
|
68
|
+
handler.call(event)
|
|
69
|
+
rescue => e
|
|
70
|
+
Console.error(self) { "Handler #{handler.class.name} raised #{e.class}: #{e.message}" }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def handler_count
|
|
77
|
+
@handlers.values.flatten.size
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
__END__
|
|
85
|
+
describe "Async::Matrix::ApplicationService::TransactionHandler" do
|
|
86
|
+
it "registers and dispatches to handlers" do
|
|
87
|
+
received = []
|
|
88
|
+
handler = Object.new
|
|
89
|
+
handler.define_singleton_method(:event_types) { ["m.room.message"] }
|
|
90
|
+
handler.define_singleton_method(:call) { |event| received << event }
|
|
91
|
+
|
|
92
|
+
transaction_handler = Async::Matrix::ApplicationService::TransactionHandler.new
|
|
93
|
+
transaction_handler.register(handler)
|
|
94
|
+
transaction_handler.handler_count.should == 1
|
|
95
|
+
|
|
96
|
+
event = Async::Matrix::ApplicationService::Event.new({
|
|
97
|
+
"type" => "m.room.message",
|
|
98
|
+
"content" => {"body" => "hi"}
|
|
99
|
+
})
|
|
100
|
+
transaction_handler.dispatch(event)
|
|
101
|
+
received.length.should == 1
|
|
102
|
+
received.first.content.body.should == "hi"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "ignores events with no matching handler" do
|
|
106
|
+
transaction_handler = Async::Matrix::ApplicationService::TransactionHandler.new
|
|
107
|
+
event = Async::Matrix::ApplicationService::Event.new({"type" => "m.unknown"})
|
|
108
|
+
lambda { transaction_handler.dispatch(event) }.should.not.raise
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "continues dispatching when a handler raises" do
|
|
112
|
+
results = []
|
|
113
|
+
bad_handler = Object.new
|
|
114
|
+
bad_handler.define_singleton_method(:event_types) { ["m.room.message"] }
|
|
115
|
+
bad_handler.define_singleton_method(:call) { |_| raise "boom" }
|
|
116
|
+
|
|
117
|
+
good_handler = Object.new
|
|
118
|
+
good_handler.define_singleton_method(:event_types) { ["m.room.message"] }
|
|
119
|
+
good_handler.define_singleton_method(:call) { |e| results << e }
|
|
120
|
+
|
|
121
|
+
transaction_handler = Async::Matrix::ApplicationService::TransactionHandler.new
|
|
122
|
+
transaction_handler.register(bad_handler)
|
|
123
|
+
transaction_handler.register(good_handler)
|
|
124
|
+
|
|
125
|
+
event = Async::Matrix::ApplicationService::Event.new({
|
|
126
|
+
"type" => "m.room.message",
|
|
127
|
+
"content" => {"body" => "test"}
|
|
128
|
+
})
|
|
129
|
+
transaction_handler.dispatch(event)
|
|
130
|
+
results.length.should == 1
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "dispatches a full transaction" do
|
|
134
|
+
received = []
|
|
135
|
+
handler = Object.new
|
|
136
|
+
handler.define_singleton_method(:event_types) { ["m.room.message"] }
|
|
137
|
+
handler.define_singleton_method(:call) { |e| received << e }
|
|
138
|
+
|
|
139
|
+
transaction_handler = Async::Matrix::ApplicationService::TransactionHandler.new
|
|
140
|
+
transaction_handler.register(handler)
|
|
141
|
+
|
|
142
|
+
transaction_handler.dispatch_transaction({
|
|
143
|
+
"events" => [
|
|
144
|
+
{"type" => "m.room.message", "content" => {"body" => "one"}},
|
|
145
|
+
{"type" => "m.room.message", "content" => {"body" => "two"}}
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
received.length.should == 2
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "registers a bot (object responding to #handlers)" do
|
|
152
|
+
received = []
|
|
153
|
+
handler = Object.new
|
|
154
|
+
handler.define_singleton_method(:event_types) { ["m.room.message"] }
|
|
155
|
+
handler.define_singleton_method(:call) { |e| received << e }
|
|
156
|
+
|
|
157
|
+
bot = Object.new
|
|
158
|
+
bot.define_singleton_method(:handlers) { [handler] }
|
|
159
|
+
|
|
160
|
+
transaction_handler = Async::Matrix::ApplicationService::TransactionHandler.new
|
|
161
|
+
transaction_handler.register(bot)
|
|
162
|
+
transaction_handler.handler_count.should == 1
|
|
163
|
+
|
|
164
|
+
transaction_handler.dispatch_transaction({
|
|
165
|
+
"events" => [{"type" => "m.room.message", "content" => {"body" => "hi"}}]
|
|
166
|
+
})
|
|
167
|
+
received.length.should == 1
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "processes a transaction idempotently via receive_transaction" do
|
|
171
|
+
received = []
|
|
172
|
+
handler = Object.new
|
|
173
|
+
handler.define_singleton_method(:event_types) { ["m.room.message"] }
|
|
174
|
+
handler.define_singleton_method(:call) { |e| received << e }
|
|
175
|
+
|
|
176
|
+
transaction_handler = Async::Matrix::ApplicationService::TransactionHandler.new
|
|
177
|
+
transaction_handler.register(handler)
|
|
178
|
+
|
|
179
|
+
body = {"events" => [{"type" => "m.room.message", "content" => {"body" => "hi"}}]}
|
|
180
|
+
|
|
181
|
+
transaction_handler.receive_transaction("txn1", body).should == :processed
|
|
182
|
+
transaction_handler.receive_transaction("txn1", body).should == :duplicate
|
|
183
|
+
received.length.should == 1
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
|
-
require "async/matrix"
|
|
8
|
-
|
|
9
6
|
module Async
|
|
10
7
|
module Matrix
|
|
11
8
|
module ApplicationService
|
|
@@ -43,7 +40,7 @@ module Async
|
|
|
43
40
|
end
|
|
44
41
|
end
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
__END__
|
|
47
44
|
describe "Async::Matrix::ApplicationService::TransactionStore" do
|
|
48
45
|
it "tracks seen transaction IDs" do
|
|
49
46
|
store = Async::Matrix::ApplicationService::TransactionStore.new
|
|
@@ -81,4 +78,3 @@ test do
|
|
|
81
78
|
store.seen?("txn0").should == true
|
|
82
79
|
end
|
|
83
80
|
end
|
|
84
|
-
end
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "sequel"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
@@ -80,7 +79,7 @@ module Async
|
|
|
80
79
|
end
|
|
81
80
|
end
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
__END__
|
|
84
83
|
describe "Async::Matrix::Bridge::Discord::DB::Connection" do
|
|
85
84
|
it "connects to an in-memory SQLite database" do
|
|
86
85
|
config = Object.new
|
|
@@ -140,4 +139,3 @@ test do
|
|
|
140
139
|
}.should.raise(ArgumentError)
|
|
141
140
|
end
|
|
142
141
|
end
|
|
143
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -44,7 +43,7 @@ module Async
|
|
|
44
43
|
end
|
|
45
44
|
end
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
__END__
|
|
48
47
|
describe "Async::Matrix::Bridge::Discord::DB::CachedFile" do
|
|
49
48
|
def setup_db
|
|
50
49
|
db = Sequel.sqlite
|
|
@@ -117,4 +116,3 @@ test do
|
|
|
117
116
|
db.disconnect
|
|
118
117
|
end
|
|
119
118
|
end
|
|
120
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -54,7 +53,7 @@ module Async
|
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
__END__
|
|
58
57
|
describe "Async::Matrix::Bridge::Discord::DB::Guild" do
|
|
59
58
|
def setup_db
|
|
60
59
|
db = Sequel.sqlite
|
|
@@ -119,4 +118,3 @@ test do
|
|
|
119
118
|
db.disconnect
|
|
120
119
|
end
|
|
121
120
|
end
|
|
122
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -57,7 +56,7 @@ module Async
|
|
|
57
56
|
end
|
|
58
57
|
end
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
__END__
|
|
61
60
|
describe "Async::Matrix::Bridge::Discord::DB::Message" do
|
|
62
61
|
def setup_db
|
|
63
62
|
db = Sequel.sqlite
|
|
@@ -159,4 +158,3 @@ test do
|
|
|
159
158
|
db.disconnect
|
|
160
159
|
end
|
|
161
160
|
end
|
|
162
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -55,7 +54,7 @@ module Async
|
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
__END__
|
|
59
58
|
describe "Async::Matrix::Bridge::Discord::DB::Portal" do
|
|
60
59
|
def setup_db
|
|
61
60
|
db = Sequel.sqlite
|
|
@@ -149,4 +148,3 @@ test do
|
|
|
149
148
|
db.disconnect
|
|
150
149
|
end
|
|
151
150
|
end
|
|
152
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -40,7 +39,7 @@ module Async
|
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
__END__
|
|
44
43
|
describe "Async::Matrix::Bridge::Discord::DB::Puppet" do
|
|
45
44
|
def setup_db
|
|
46
45
|
db = Sequel.sqlite
|
|
@@ -127,4 +126,3 @@ test do
|
|
|
127
126
|
db.disconnect
|
|
128
127
|
end
|
|
129
128
|
end
|
|
130
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -60,7 +59,7 @@ module Async
|
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
__END__
|
|
64
63
|
describe "Async::Matrix::Bridge::Discord::DB::Reaction" do
|
|
65
64
|
def setup_db
|
|
66
65
|
db = Sequel.sqlite
|
|
@@ -164,4 +163,3 @@ test do
|
|
|
164
163
|
db.disconnect
|
|
165
164
|
end
|
|
166
165
|
end
|
|
167
|
-
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the Apache License, Version 2.0.
|
|
4
|
+
# Copyright, 2026, by General Intelligence Systems.
|
|
5
|
+
|
|
6
|
+
require "sequel"
|
|
7
|
+
|
|
8
|
+
# Sequel::Model requires a database connection at subclass definition time.
|
|
9
|
+
# Set a placeholder in-memory SQLite so models can be defined at load time.
|
|
10
|
+
# The real database is bound later via DB.connect / DB.bind_models.
|
|
11
|
+
#
|
|
12
|
+
# require_valid_table = false suppresses the column introspection that Sequel
|
|
13
|
+
# normally does on inheritance — critical because the placeholder DB has no
|
|
14
|
+
# tables.
|
|
15
|
+
unless Sequel::Model.instance_variable_get(:@db)
|
|
16
|
+
Sequel::Model.db = Sequel.sqlite
|
|
17
|
+
Sequel::Model.require_valid_table = false
|
|
18
|
+
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "schema"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -37,7 +36,7 @@ module Async
|
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
__END__
|
|
41
40
|
describe "Async::Matrix::Bridge::Discord::DB::User" do
|
|
42
41
|
def setup_db
|
|
43
42
|
db = Sequel.sqlite
|
|
@@ -111,4 +110,3 @@ test do
|
|
|
111
110
|
db.disconnect
|
|
112
111
|
end
|
|
113
112
|
end
|
|
114
|
-
end
|
|
@@ -3,22 +3,21 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "sequel"
|
|
8
7
|
require "sequel/extensions/migration"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Sequel
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
|
|
9
|
+
# The Discord bridge's database layer. Requiring this file loads the whole
|
|
10
|
+
# subsystem: the Sequel placeholder (schema), the connection helper, and every
|
|
11
|
+
# model class, so DB.connect can bind them all.
|
|
12
|
+
require_relative "db/schema"
|
|
13
|
+
require_relative "db/connection"
|
|
14
|
+
require_relative "db/user"
|
|
15
|
+
require_relative "db/guild"
|
|
16
|
+
require_relative "db/portal"
|
|
17
|
+
require_relative "db/puppet"
|
|
18
|
+
require_relative "db/message"
|
|
19
|
+
require_relative "db/reaction"
|
|
20
|
+
require_relative "db/file"
|
|
22
21
|
|
|
23
22
|
module Async
|
|
24
23
|
module Matrix
|
|
@@ -75,7 +74,7 @@ module Async
|
|
|
75
74
|
end
|
|
76
75
|
end
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
__END__
|
|
79
78
|
describe "Async::Matrix::Bridge::Discord::DB" do
|
|
80
79
|
it "connects, migrates, and binds models from config" do
|
|
81
80
|
database_config = Object.new
|
|
@@ -137,4 +136,3 @@ test do
|
|
|
137
136
|
db.disconnect
|
|
138
137
|
end
|
|
139
138
|
end
|
|
140
|
-
end
|
data/lib/async/matrix/client.rb
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "async/http/internet"
|
|
8
|
-
require "async/matrix"
|
|
9
7
|
require "json"
|
|
10
8
|
require "erb"
|
|
11
9
|
require "console"
|
|
@@ -323,7 +321,7 @@ module Async
|
|
|
323
321
|
end
|
|
324
322
|
end
|
|
325
323
|
|
|
326
|
-
|
|
324
|
+
__END__
|
|
327
325
|
describe "Async::Matrix::Client" do
|
|
328
326
|
def make_config
|
|
329
327
|
Async::Matrix::ApplicationService::Config.new({
|
|
@@ -934,4 +932,3 @@ test do
|
|
|
934
932
|
result.should.be.nil
|
|
935
933
|
end
|
|
936
934
|
end
|
|
937
|
-
end
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "async/http"
|
|
8
|
-
require "async/matrix"
|
|
9
7
|
|
|
10
8
|
module Async
|
|
11
9
|
module Matrix
|
|
@@ -15,8 +13,7 @@ module Async
|
|
|
15
13
|
end
|
|
16
14
|
end
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
__END__
|
|
19
17
|
it "includes Async::HTTP::Protocol::HTTP2::Connection" do
|
|
20
18
|
Async::Matrix::Connection.ancestors.should.include Async::HTTP::Protocol::HTTP2::Connection
|
|
21
19
|
end
|
|
22
|
-
end
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require "async/matrix"
|
|
6
|
+
require_relative "client"
|
|
8
7
|
|
|
9
8
|
module Async
|
|
10
9
|
module Matrix
|
|
@@ -27,7 +26,7 @@ module Async
|
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
__END__
|
|
31
30
|
describe "Async::Matrix::DoublePuppetClient" do
|
|
32
31
|
def make_config
|
|
33
32
|
Async::Matrix::ApplicationService::Config.new({
|
|
@@ -81,4 +80,3 @@ test do
|
|
|
81
80
|
puppet.should.be.kind_of Async::Matrix::Client
|
|
82
81
|
end
|
|
83
82
|
end
|
|
84
|
-
end
|
data/lib/async/matrix/e2ee.rb
CHANGED
|
@@ -27,7 +27,7 @@ end
|
|
|
27
27
|
# rake-compiler installs the shared object alongside this file.
|
|
28
28
|
require_relative "async_matrix_e2ee"
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
__END__
|
|
31
31
|
describe "Async::Matrix::E2EE" do
|
|
32
32
|
it "exposes account identity keys as base64" do
|
|
33
33
|
account = Async::Matrix::E2EE::Account.new
|
|
@@ -82,4 +82,3 @@ test do
|
|
|
82
82
|
restored.session_id.should == group.session_id
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
|
-
end
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "json"
|
|
8
7
|
require "async/http"
|
|
9
|
-
require "async/matrix"
|
|
10
8
|
|
|
11
9
|
module Async
|
|
12
10
|
module Matrix
|
|
@@ -38,7 +36,7 @@ module Async
|
|
|
38
36
|
end
|
|
39
37
|
end
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
__END__
|
|
42
40
|
it "defines the WELL_KNOWN constant" do
|
|
43
41
|
Async::Matrix::Endpoint::WELL_KNOWN.should == "/.well-known/matrix/client"
|
|
44
42
|
end
|
|
@@ -57,4 +55,3 @@ test do
|
|
|
57
55
|
endpoint.to_s.should =~ /nonexistent\.invalid/
|
|
58
56
|
end.wait
|
|
59
57
|
end
|
|
60
|
-
end
|
data/lib/async/matrix/error.rb
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
|
-
|
|
8
6
|
module Async
|
|
9
7
|
module Matrix
|
|
10
8
|
class Error < StandardError
|
|
@@ -26,7 +24,7 @@ module Async
|
|
|
26
24
|
end
|
|
27
25
|
end
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
__END__
|
|
30
28
|
describe "Async::Matrix::Error" do
|
|
31
29
|
it "stores errcode and message" do
|
|
32
30
|
err = Async::Matrix::Error.new("M_UNKNOWN", "something broke")
|
|
@@ -67,4 +65,3 @@ test do
|
|
|
67
65
|
it "ResponseTooLargeError inherits from Error" do
|
|
68
66
|
Async::Matrix::ResponseTooLargeError.new("M_TOO_LARGE", "too big").should.be.kind_of Async::Matrix::Error
|
|
69
67
|
end
|
|
70
|
-
end
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "async/http/internet"
|
|
8
|
-
require "async/matrix"
|
|
9
7
|
require "json"
|
|
10
8
|
require "console"
|
|
11
9
|
|
|
@@ -150,7 +148,7 @@ module Async
|
|
|
150
148
|
end
|
|
151
149
|
end
|
|
152
150
|
|
|
153
|
-
|
|
151
|
+
__END__
|
|
154
152
|
describe "Async::Matrix::MediaClient" do
|
|
155
153
|
def make_config
|
|
156
154
|
Async::Matrix::ApplicationService::Config.new({
|
|
@@ -170,4 +168,3 @@ test do
|
|
|
170
168
|
lambda { client.close }.should.not.raise
|
|
171
169
|
end
|
|
172
170
|
end
|
|
173
|
-
end
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
# Released under the Apache License, Version 2.0.
|
|
4
4
|
# Copyright, 2026, by General Intelligence Systems.
|
|
5
5
|
|
|
6
|
-
require "bundler/setup"
|
|
7
6
|
require "async"
|
|
8
7
|
require "async/condition"
|
|
9
|
-
require "async/matrix"
|
|
10
8
|
|
|
11
9
|
module Async
|
|
12
10
|
module Matrix
|
|
@@ -57,7 +55,7 @@ module Async
|
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
__END__
|
|
61
59
|
it "can be instantiated" do
|
|
62
60
|
notifier = Async::Matrix::Notifier.new
|
|
63
61
|
notifier.should.be.kind_of Async::Matrix::Notifier
|
|
@@ -104,4 +102,3 @@ test do
|
|
|
104
102
|
end.wait
|
|
105
103
|
result.should == true
|
|
106
104
|
end
|
|
107
|
-
end
|
|
@@ -234,7 +234,7 @@ module Async
|
|
|
234
234
|
end
|
|
235
235
|
end
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
__END__
|
|
238
238
|
describe "Async::Matrix::Schema::Registry" do
|
|
239
239
|
it "loads schemas from disk" do
|
|
240
240
|
Async::Matrix::Schema::Registry.instance.size.should.be > 0
|
|
@@ -352,4 +352,3 @@ test do
|
|
|
352
352
|
Async::Matrix::Schema::Registry.instance.validate(event).should == []
|
|
353
353
|
end
|
|
354
354
|
end
|
|
355
|
-
end
|