matrix_sdk 2.1.3 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +1 -1
- data/lib/matrix_sdk/api.rb +49 -32
- data/lib/matrix_sdk/client.rb +71 -54
- data/lib/matrix_sdk/errors.rb +4 -0
- data/lib/matrix_sdk/mxid.rb +50 -15
- data/lib/matrix_sdk/protocols/cs.rb +182 -124
- data/lib/matrix_sdk/protocols/msc.rb +5 -1
- data/lib/matrix_sdk/response.rb +3 -1
- data/lib/matrix_sdk/room.rb +335 -102
- data/lib/matrix_sdk/rooms/space.rb +79 -0
- data/lib/matrix_sdk/user.rb +11 -3
- data/lib/matrix_sdk/util/events.rb +111 -0
- data/lib/matrix_sdk/util/extensions.rb +75 -0
- data/lib/matrix_sdk/util/tinycache.rb +134 -0
- data/lib/matrix_sdk/util/tinycache_adapter.rb +77 -0
- data/lib/matrix_sdk/util/uri.rb +89 -0
- data/lib/matrix_sdk/version.rb +1 -1
- data/lib/matrix_sdk.rb +16 -1
- metadata +12 -8
- data/lib/matrix_sdk/application_service.rb +0 -212
- data/lib/matrix_sdk/extensions.rb +0 -197
@@ -13,8 +13,10 @@ module MatrixSdk::Protocols::CS
|
|
13
13
|
def client_api_versions
|
14
14
|
(@client_api_versions ||= request(:get, :client, '/versions')).versions.tap do |vers|
|
15
15
|
vers.instance_eval <<-'CODE', __FILE__, __LINE__ + 1
|
16
|
-
|
17
|
-
|
16
|
+
if !respond_to? :latest
|
17
|
+
def latest
|
18
|
+
last
|
19
|
+
end
|
18
20
|
end
|
19
21
|
CODE
|
20
22
|
end
|
@@ -39,10 +41,20 @@ module MatrixSdk::Protocols::CS
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
44
|
+
# Gets the latest version of the client API
|
45
|
+
# @return [Symbol] :client_r0 / :client_v3 / etc
|
46
|
+
def client_api_latest
|
47
|
+
@client_api_latest ||= :client_v3 if client_api_versions.any? { |v| v.start_with? 'v1.1' }
|
48
|
+
@client_api_latest ||= :client_r0
|
49
|
+
rescue StandardError => e
|
50
|
+
logger.warn "Failed to look up supported client API, defaulting to r0. The error was #{e.class}: #{e}"
|
51
|
+
@client_api_latest ||= :client_r0
|
52
|
+
end
|
53
|
+
|
42
54
|
# Gets the list of available methods for logging in
|
43
55
|
# @return [Response]
|
44
56
|
def allowed_login_methods
|
45
|
-
request(:get,
|
57
|
+
request(:get, client_api_latest, '/login')
|
46
58
|
end
|
47
59
|
|
48
60
|
# Runs the client API /sync method
|
@@ -64,7 +76,7 @@ module MatrixSdk::Protocols::CS
|
|
64
76
|
query[:timeout] = params.delete(:timeout_ms).to_i if params.key? :timeout_ms
|
65
77
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
66
78
|
|
67
|
-
request(:get,
|
79
|
+
request(:get, client_api_latest, '/sync', query: query)
|
68
80
|
end
|
69
81
|
|
70
82
|
# Registers a user using the client API /register endpoint
|
@@ -90,7 +102,7 @@ module MatrixSdk::Protocols::CS
|
|
90
102
|
store_token = params.delete(:store_token) { !protocol?(:AS) }
|
91
103
|
store_device_id = params.delete(:store_device_id) { store_token }
|
92
104
|
|
93
|
-
request(:post,
|
105
|
+
request(:post, client_api_latest, '/register', body: params, query: query).tap do |resp|
|
94
106
|
@access_token = resp.token if resp.key?(:token) && store_token
|
95
107
|
@device_id = resp.device_id if resp.key?(:device_id) && store_device_id
|
96
108
|
end
|
@@ -113,7 +125,7 @@ module MatrixSdk::Protocols::CS
|
|
113
125
|
next_link: next_link
|
114
126
|
}.compact
|
115
127
|
|
116
|
-
request(:post,
|
128
|
+
request(:post, client_api_latest, '/register/email/requestToken', body: body)
|
117
129
|
end
|
118
130
|
|
119
131
|
# Requests to register a phone number to the current account
|
@@ -135,7 +147,7 @@ module MatrixSdk::Protocols::CS
|
|
135
147
|
next_link: next_link
|
136
148
|
}.compact
|
137
149
|
|
138
|
-
request(:post,
|
150
|
+
request(:post, client_api_latest, '/register/msisdn/requestToken', body: body)
|
139
151
|
end
|
140
152
|
|
141
153
|
# Checks if a given username is available and valid for registering
|
@@ -148,7 +160,7 @@ module MatrixSdk::Protocols::CS
|
|
148
160
|
# @return [Response]
|
149
161
|
# @see https://matrix.org/docs/spec/client_server/latest.html#get-matrix-client-r0-register-available
|
150
162
|
def username_available?(username)
|
151
|
-
request(:get,
|
163
|
+
request(:get, client_api_latest, '/register/available', query: { username: username })
|
152
164
|
end
|
153
165
|
|
154
166
|
# Logs in using the client API /login endpoint, and optionally stores the resulting access for API usage
|
@@ -190,7 +202,7 @@ module MatrixSdk::Protocols::CS
|
|
190
202
|
}.merge params
|
191
203
|
data[:device_id] = device_id if device_id
|
192
204
|
|
193
|
-
request(:post,
|
205
|
+
request(:post, client_api_latest, '/login', body: data, query: query).tap do |resp|
|
194
206
|
@access_token = resp.token if resp.key?(:token) && options[:store_token]
|
195
207
|
@device_id = resp.device_id if resp.key?(:device_id) && options[:store_device_id]
|
196
208
|
end
|
@@ -204,7 +216,7 @@ module MatrixSdk::Protocols::CS
|
|
204
216
|
query = {}
|
205
217
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
206
218
|
|
207
|
-
request(:post,
|
219
|
+
request(:post, client_api_latest, '/logout', query: query)
|
208
220
|
end
|
209
221
|
|
210
222
|
# Logs out the currently logged in user
|
@@ -215,7 +227,7 @@ module MatrixSdk::Protocols::CS
|
|
215
227
|
query = {}
|
216
228
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
217
229
|
|
218
|
-
request(:post,
|
230
|
+
request(:post, client_api_latest, '/logout/all', query: query)
|
219
231
|
end
|
220
232
|
|
221
233
|
# Changes the users password
|
@@ -235,7 +247,7 @@ module MatrixSdk::Protocols::CS
|
|
235
247
|
auth: auth
|
236
248
|
}
|
237
249
|
|
238
|
-
request(:post,
|
250
|
+
request(:post, client_api_latest, '/account/password', body: body, query: query)
|
239
251
|
end
|
240
252
|
|
241
253
|
# Requests an authentication token based on an email address
|
@@ -255,7 +267,7 @@ module MatrixSdk::Protocols::CS
|
|
255
267
|
next_link: next_link
|
256
268
|
}.compact
|
257
269
|
|
258
|
-
request(:post,
|
270
|
+
request(:post, client_api_latest, '/account/password/email/requestToken', body: body)
|
259
271
|
end
|
260
272
|
|
261
273
|
# Requests an authentication token based on a phone number
|
@@ -277,7 +289,7 @@ module MatrixSdk::Protocols::CS
|
|
277
289
|
next_link: next_link
|
278
290
|
}.compact
|
279
291
|
|
280
|
-
request(:post,
|
292
|
+
request(:post, client_api_latest, '/account/password/msisdn/requestToken', body: body)
|
281
293
|
end
|
282
294
|
|
283
295
|
# Deactivates the current account, logging out all connected devices and preventing future logins
|
@@ -293,14 +305,14 @@ module MatrixSdk::Protocols::CS
|
|
293
305
|
id_server: id_server
|
294
306
|
}.compact
|
295
307
|
|
296
|
-
request(:post,
|
308
|
+
request(:post, client_api_latest, '/account/deactivate', body: body)
|
297
309
|
end
|
298
310
|
|
299
311
|
def get_3pids(**params)
|
300
312
|
query = {}
|
301
313
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
302
314
|
|
303
|
-
request(:get,
|
315
|
+
request(:get, client_api_latest, '/account/3pid', query: query)
|
304
316
|
end
|
305
317
|
|
306
318
|
# Finishes a 3PID addition to the current user
|
@@ -318,7 +330,7 @@ module MatrixSdk::Protocols::CS
|
|
318
330
|
auth: auth_data
|
319
331
|
}.compact
|
320
332
|
|
321
|
-
request(:post,
|
333
|
+
request(:post, client_api_latest, '/account/3pid/add', body: body)
|
322
334
|
end
|
323
335
|
|
324
336
|
# Finishes binding a 3PID to the current user
|
@@ -338,7 +350,7 @@ module MatrixSdk::Protocols::CS
|
|
338
350
|
sid: session
|
339
351
|
}
|
340
352
|
|
341
|
-
request(:post,
|
353
|
+
request(:post, client_api_latest, '/account/3pid/bind', body: body)
|
342
354
|
end
|
343
355
|
|
344
356
|
# Deletes a 3PID from the current user, this method might not unbind it from the identity server
|
@@ -356,7 +368,7 @@ module MatrixSdk::Protocols::CS
|
|
356
368
|
medium: medium
|
357
369
|
}
|
358
370
|
|
359
|
-
request(:post,
|
371
|
+
request(:post, client_api_latest, '/account/3pid/delete', body: body)
|
360
372
|
end
|
361
373
|
|
362
374
|
# Unbinds a 3PID from the current user
|
@@ -374,7 +386,7 @@ module MatrixSdk::Protocols::CS
|
|
374
386
|
medium: medium
|
375
387
|
}
|
376
388
|
|
377
|
-
request(:post,
|
389
|
+
request(:post, client_api_latest, '/account/3pid/unbind', body: body)
|
378
390
|
end
|
379
391
|
|
380
392
|
# Gets the list of rooms joined by the current user
|
@@ -385,7 +397,7 @@ module MatrixSdk::Protocols::CS
|
|
385
397
|
query = {}
|
386
398
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
387
399
|
|
388
|
-
request(:get,
|
400
|
+
request(:get, client_api_latest, '/joined_rooms', query: query)
|
389
401
|
end
|
390
402
|
|
391
403
|
# Gets the list of public rooms on a Matrix server
|
@@ -418,7 +430,7 @@ module MatrixSdk::Protocols::CS
|
|
418
430
|
query = query.merge(params).compact
|
419
431
|
end
|
420
432
|
|
421
|
-
request(method,
|
433
|
+
request(method, client_api_latest, '/publicRooms', query: query, body: body)
|
422
434
|
end
|
423
435
|
|
424
436
|
# Creates a new room
|
@@ -440,7 +452,29 @@ module MatrixSdk::Protocols::CS
|
|
440
452
|
content[:invite] = [params.delete(:invite)].flatten if params[:invite]
|
441
453
|
content.merge! params
|
442
454
|
|
443
|
-
request(:post,
|
455
|
+
request(:post, client_api_latest, '/createRoom', body: content, query: query)
|
456
|
+
end
|
457
|
+
|
458
|
+
# Knock on a room
|
459
|
+
#
|
460
|
+
# @param id_or_alias [MXID,String] The room ID or Alias to knock
|
461
|
+
# @param reason [String] A reason for the knock, will be attached to the membership data
|
462
|
+
# @param server_name [String[]] A list of servers to perform the join through
|
463
|
+
# @param params [Hash] Extra room knock options
|
464
|
+
# @return [Response] A response hash with at least the parameter :room_id
|
465
|
+
# @see https://spec.matrix.org/v1.1/client-server-api/#knocking-on-rooms
|
466
|
+
# The Matrix Spec, for more information about the call and response
|
467
|
+
def knock_room(id_or_alias, reason: nil, server_name: nil, **params)
|
468
|
+
query = {}
|
469
|
+
query[:server_name] = server_name if server_name
|
470
|
+
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
471
|
+
|
472
|
+
content = {}
|
473
|
+
content[:reason] = reason if reason
|
474
|
+
|
475
|
+
id_or_alias = ERB::Util.url_encode id_or_alias.to_s
|
476
|
+
|
477
|
+
request(:post, client_api_latest, "/knock/#{id_or_alias}", body: content, query: query)
|
444
478
|
end
|
445
479
|
|
446
480
|
# Joins a room
|
@@ -451,17 +485,17 @@ module MatrixSdk::Protocols::CS
|
|
451
485
|
# @see https://matrix.org/docs/spec/client_server/latest.html#post-matrix-client-r0-join-roomidoralias
|
452
486
|
# The Matrix Spec, for more information about the call and response
|
453
487
|
# @todo Add support for 3rd-party signed objects
|
454
|
-
def join_room(id_or_alias, **params)
|
488
|
+
def join_room(id_or_alias, reason: nil, **params)
|
455
489
|
query = {}
|
456
490
|
query[:server_name] = params[:server_name] if params[:server_name]
|
457
491
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
458
492
|
|
459
|
-
|
460
|
-
|
493
|
+
content = {}
|
494
|
+
content[:reason] = reason if reason
|
461
495
|
|
462
496
|
id_or_alias = ERB::Util.url_encode id_or_alias.to_s
|
463
497
|
|
464
|
-
request(:post,
|
498
|
+
request(:post, client_api_latest, "/join/#{id_or_alias}", body: content, query: query)
|
465
499
|
end
|
466
500
|
|
467
501
|
# Sends a state event to a room
|
@@ -482,7 +516,7 @@ module MatrixSdk::Protocols::CS
|
|
482
516
|
event_type = ERB::Util.url_encode event_type.to_s
|
483
517
|
state_key = ERB::Util.url_encode params[:state_key].to_s if params.key? :state_key
|
484
518
|
|
485
|
-
request(:put,
|
519
|
+
request(:put, client_api_latest, "/rooms/#{room_id}/state/#{event_type}#{"/#{state_key}" unless state_key.nil?}", body: content, query: query)
|
486
520
|
end
|
487
521
|
|
488
522
|
# Sends a message event to a room
|
@@ -505,7 +539,7 @@ module MatrixSdk::Protocols::CS
|
|
505
539
|
event_type = ERB::Util.url_encode event_type.to_s
|
506
540
|
txn_id = ERB::Util.url_encode txn_id.to_s
|
507
541
|
|
508
|
-
request(:put,
|
542
|
+
request(:put, client_api_latest, "/rooms/#{room_id}/send/#{event_type}/#{txn_id}", body: content, query: query)
|
509
543
|
end
|
510
544
|
|
511
545
|
# Redact an event in a room
|
@@ -531,7 +565,7 @@ module MatrixSdk::Protocols::CS
|
|
531
565
|
event_id = ERB::Util.url_encode event_id.to_s
|
532
566
|
txn_id = ERB::Util.url_encode txn_id.to_s
|
533
567
|
|
534
|
-
request(:put,
|
568
|
+
request(:put, client_api_latest, "/rooms/#{room_id}/redact/#{event_id}/#{txn_id}", body: content, query: query)
|
535
569
|
end
|
536
570
|
|
537
571
|
# Send a content message to a room
|
@@ -584,7 +618,7 @@ module MatrixSdk::Protocols::CS
|
|
584
618
|
}
|
585
619
|
content.merge!(params.fetch(:extra_content)) if params.key? :extra_content
|
586
620
|
|
587
|
-
send_message_event(room_id, 'm.room.message', content, params)
|
621
|
+
send_message_event(room_id, 'm.room.message', content, **params)
|
588
622
|
end
|
589
623
|
|
590
624
|
# Send a geographic location to a room
|
@@ -610,7 +644,7 @@ module MatrixSdk::Protocols::CS
|
|
610
644
|
content[:info][:thumbnail_url] = params.delete(:thumbnail_url) if params.key? :thumbnail_url
|
611
645
|
content[:info][:thumbnail_info] = params.delete(:thumbnail_info) if params.key? :thumbnail_info
|
612
646
|
|
613
|
-
send_message_event(room_id, 'm.room.message', content, params)
|
647
|
+
send_message_event(room_id, 'm.room.message', content, **params)
|
614
648
|
end
|
615
649
|
|
616
650
|
# Send a plaintext message to a room
|
@@ -628,7 +662,7 @@ module MatrixSdk::Protocols::CS
|
|
628
662
|
msgtype: params.delete(:msg_type) { 'm.text' },
|
629
663
|
body: message
|
630
664
|
}
|
631
|
-
send_message_event(room_id, 'm.room.message', content, params)
|
665
|
+
send_message_event(room_id, 'm.room.message', content, **params)
|
632
666
|
end
|
633
667
|
|
634
668
|
# Send a plaintext emote to a room
|
@@ -646,7 +680,7 @@ module MatrixSdk::Protocols::CS
|
|
646
680
|
msgtype: params.delete(:msg_type) { 'm.emote' },
|
647
681
|
body: emote
|
648
682
|
}
|
649
|
-
send_message_event(room_id, 'm.room.message', content, params)
|
683
|
+
send_message_event(room_id, 'm.room.message', content, **params)
|
650
684
|
end
|
651
685
|
|
652
686
|
# Send a plaintext notice to a room
|
@@ -664,7 +698,7 @@ module MatrixSdk::Protocols::CS
|
|
664
698
|
msgtype: params.delete(:msg_type) { 'm.notice' },
|
665
699
|
body: notice
|
666
700
|
}
|
667
|
-
send_message_event(room_id, 'm.room.message', content, params)
|
701
|
+
send_message_event(room_id, 'm.room.message', content, **params)
|
668
702
|
end
|
669
703
|
|
670
704
|
# Report an event in a room
|
@@ -687,7 +721,7 @@ module MatrixSdk::Protocols::CS
|
|
687
721
|
room_id = ERB::Util.url_encode room_id.to_s
|
688
722
|
event_id = ERB::Util.url_encode event_id.to_s
|
689
723
|
|
690
|
-
request(:post,
|
724
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/report/#{event_id}", body: body, query: query)
|
691
725
|
end
|
692
726
|
|
693
727
|
# Retrieve additional messages in a room
|
@@ -702,7 +736,7 @@ module MatrixSdk::Protocols::CS
|
|
702
736
|
# @return [Response] A response hash with the message information containing :start, :end, and :chunk fields
|
703
737
|
# @see https://matrix.org/docs/spec/client_server/latest.html#get-matrix-client-r0-rooms-roomid-messages
|
704
738
|
# The Matrix Spec, for more information about the call and response
|
705
|
-
def get_room_messages(room_id, token, direction
|
739
|
+
def get_room_messages(room_id, token, direction:, limit: 10, **params)
|
706
740
|
query = {
|
707
741
|
from: token,
|
708
742
|
dir: direction,
|
@@ -714,7 +748,7 @@ module MatrixSdk::Protocols::CS
|
|
714
748
|
|
715
749
|
room_id = ERB::Util.url_encode room_id.to_s
|
716
750
|
|
717
|
-
request(:get,
|
751
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/messages", query: query)
|
718
752
|
end
|
719
753
|
|
720
754
|
# Gets a specific event from a room
|
@@ -731,7 +765,7 @@ module MatrixSdk::Protocols::CS
|
|
731
765
|
room_id = ERB::Util.url_encode room_id.to_s
|
732
766
|
event_id = ERB::Util.url_encode event_id.to_s
|
733
767
|
|
734
|
-
request(:get,
|
768
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/event/#{event_id}", query: query)
|
735
769
|
end
|
736
770
|
|
737
771
|
# Reads the latest instance of a room state event
|
@@ -749,7 +783,7 @@ module MatrixSdk::Protocols::CS
|
|
749
783
|
state_type = ERB::Util.url_encode state_type.to_s
|
750
784
|
key = ERB::Util.url_encode key.to_s
|
751
785
|
|
752
|
-
request(:get,
|
786
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/state/#{state_type}#{key.empty? ? nil : "/#{key}"}", query: query)
|
753
787
|
end
|
754
788
|
|
755
789
|
# Retrieves all current state objects from a room
|
@@ -764,7 +798,31 @@ module MatrixSdk::Protocols::CS
|
|
764
798
|
|
765
799
|
room_id = ERB::Util.url_encode room_id.to_s
|
766
800
|
|
767
|
-
request(:get,
|
801
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/state", query: query)
|
802
|
+
end
|
803
|
+
|
804
|
+
# Retrieves number of events that happened just before and after the specified event
|
805
|
+
#
|
806
|
+
# @param room_id [MXID,String] The room to get events from.
|
807
|
+
# @param event_id [MXID,String] The event to get context around.
|
808
|
+
# @option params [Integer] :limit (10) The limit of messages to retrieve
|
809
|
+
# @option params [String] :filter A filter to limit the retrieval to
|
810
|
+
# @return [Response] A response hash with contextual event information
|
811
|
+
# @see https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-context-eventid
|
812
|
+
# The Matrix Spec, for more information about the call and response
|
813
|
+
# @example Find event context with filter and limit specified
|
814
|
+
# api.get_room_event_context('#room:example.com', '$event_id:example.com', filter: { types: ['m.room.message'] }.to_json, limit: 20)
|
815
|
+
def get_room_event_context(room_id, event_id, **params)
|
816
|
+
query = {}
|
817
|
+
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
818
|
+
|
819
|
+
query[:limit] = params.fetch(:limit) if params.key? :limit
|
820
|
+
query[:filter] = params.fetch(:filter) if params.key? :filter
|
821
|
+
|
822
|
+
room_id = ERB::Util.url_encode room_id.to_s
|
823
|
+
event_id = ERB::Util.url_encode event_id.to_s
|
824
|
+
|
825
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/context/#{event_id}", query: query)
|
768
826
|
end
|
769
827
|
|
770
828
|
## Specialized getters for specced state
|
@@ -780,7 +838,7 @@ module MatrixSdk::Protocols::CS
|
|
780
838
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-name
|
781
839
|
# The Matrix Spec, for more information about the event and data
|
782
840
|
def get_room_name(room_id, **params)
|
783
|
-
get_room_state(room_id, 'm.room.name', params)
|
841
|
+
get_room_state(room_id, 'm.room.name', **params)
|
784
842
|
end
|
785
843
|
|
786
844
|
# Sets the display name of a room
|
@@ -795,7 +853,7 @@ module MatrixSdk::Protocols::CS
|
|
795
853
|
content = {
|
796
854
|
name: name
|
797
855
|
}
|
798
|
-
send_state_event(room_id, 'm.room.name', content, params)
|
856
|
+
send_state_event(room_id, 'm.room.name', content, **params)
|
799
857
|
end
|
800
858
|
|
801
859
|
# Gets the current topic of a room
|
@@ -808,7 +866,7 @@ module MatrixSdk::Protocols::CS
|
|
808
866
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-topic
|
809
867
|
# The Matrix Spec, for more information about the event and data
|
810
868
|
def get_room_topic(room_id, **params)
|
811
|
-
get_room_state(room_id, 'm.room.topic', params)
|
869
|
+
get_room_state(room_id, 'm.room.topic', **params)
|
812
870
|
end
|
813
871
|
|
814
872
|
# Sets the topic of a room
|
@@ -823,7 +881,7 @@ module MatrixSdk::Protocols::CS
|
|
823
881
|
content = {
|
824
882
|
topic: topic
|
825
883
|
}
|
826
|
-
send_state_event(room_id, 'm.room.topic', content, params)
|
884
|
+
send_state_event(room_id, 'm.room.topic', content, **params)
|
827
885
|
end
|
828
886
|
|
829
887
|
# Gets the current avatar URL of a room
|
@@ -836,7 +894,7 @@ module MatrixSdk::Protocols::CS
|
|
836
894
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-avatar
|
837
895
|
# The Matrix Spec, for more information about the event and data
|
838
896
|
def get_room_avatar(room_id, **params)
|
839
|
-
get_room_state(room_id, 'm.room.avatar', params)
|
897
|
+
get_room_state(room_id, 'm.room.avatar', **params)
|
840
898
|
end
|
841
899
|
|
842
900
|
# Sets the avatar URL for a room
|
@@ -851,7 +909,7 @@ module MatrixSdk::Protocols::CS
|
|
851
909
|
content = {
|
852
910
|
url: url
|
853
911
|
}
|
854
|
-
send_state_event(room_id, 'm.room.avatar', content, params)
|
912
|
+
send_state_event(room_id, 'm.room.avatar', content, **params)
|
855
913
|
end
|
856
914
|
|
857
915
|
# Gets a list of current aliases of a room
|
@@ -878,7 +936,7 @@ module MatrixSdk::Protocols::CS
|
|
878
936
|
# .compact
|
879
937
|
# # => ["#synapse:im.kabi.tk", "#synapse:matrix.org", "#synapse-community:matrix.org", "#synapse-ops:matrix.org", "#synops:matrix.org", ...
|
880
938
|
def get_room_aliases(room_id, **params)
|
881
|
-
get_room_state(room_id, 'm.room.aliases', params)
|
939
|
+
get_room_state(room_id, 'm.room.aliases', **params)
|
882
940
|
end
|
883
941
|
|
884
942
|
# Gets a list of pinned events in a room
|
@@ -891,7 +949,7 @@ module MatrixSdk::Protocols::CS
|
|
891
949
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-pinned-events
|
892
950
|
# The Matrix Spec, for more information about the event and data
|
893
951
|
def get_room_pinned_events(room_id, **params)
|
894
|
-
get_room_state(room_id, 'm.room.pinned_events', params)
|
952
|
+
get_room_state(room_id, 'm.room.pinned_events', **params)
|
895
953
|
end
|
896
954
|
|
897
955
|
# Sets the list of pinned events in a room
|
@@ -906,7 +964,7 @@ module MatrixSdk::Protocols::CS
|
|
906
964
|
content = {
|
907
965
|
pinned: events
|
908
966
|
}
|
909
|
-
send_state_event(room_id, 'm.room.pinned_events', content, params)
|
967
|
+
send_state_event(room_id, 'm.room.pinned_events', content, **params)
|
910
968
|
end
|
911
969
|
|
912
970
|
# Gets the configured power levels for a room
|
@@ -918,7 +976,7 @@ module MatrixSdk::Protocols::CS
|
|
918
976
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-power-levels
|
919
977
|
# The Matrix Spec, for more information about the event and data
|
920
978
|
def get_room_power_levels(room_id, **params)
|
921
|
-
get_room_state(room_id, 'm.room.power_levels', params)
|
979
|
+
get_room_state(room_id, 'm.room.power_levels', **params)
|
922
980
|
end
|
923
981
|
alias get_power_levels get_room_power_levels
|
924
982
|
|
@@ -932,7 +990,7 @@ module MatrixSdk::Protocols::CS
|
|
932
990
|
# The Matrix Spec, for more information about the event and data
|
933
991
|
def set_room_power_levels(room_id, content, **params)
|
934
992
|
content[:events] = {} unless content.key? :events
|
935
|
-
send_state_event(room_id, 'm.room.power_levels', content, params)
|
993
|
+
send_state_event(room_id, 'm.room.power_levels', content, **params)
|
936
994
|
end
|
937
995
|
alias set_power_levels set_room_power_levels
|
938
996
|
|
@@ -945,7 +1003,7 @@ module MatrixSdk::Protocols::CS
|
|
945
1003
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-join-rules
|
946
1004
|
# The Matrix Spec, for more information about the event and data
|
947
1005
|
def get_room_join_rules(room_id, **params)
|
948
|
-
get_room_state(room_id, 'm.room.join_rules', params)
|
1006
|
+
get_room_state(room_id, 'm.room.join_rules', **params)
|
949
1007
|
end
|
950
1008
|
|
951
1009
|
# Sets the join rules for a room
|
@@ -961,7 +1019,7 @@ module MatrixSdk::Protocols::CS
|
|
961
1019
|
join_rule: join_rule
|
962
1020
|
}
|
963
1021
|
|
964
|
-
send_state_event(room_id, 'm.room.join_rules', content, params)
|
1022
|
+
send_state_event(room_id, 'm.room.join_rules', content, **params)
|
965
1023
|
end
|
966
1024
|
|
967
1025
|
# Gets the guest access settings for a room
|
@@ -973,7 +1031,7 @@ module MatrixSdk::Protocols::CS
|
|
973
1031
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-guest-access
|
974
1032
|
# The Matrix Spec, for more information about the event and data
|
975
1033
|
def get_room_guest_access(room_id, **params)
|
976
|
-
get_room_state(room_id, 'm.room.guest_access', params)
|
1034
|
+
get_room_state(room_id, 'm.room.guest_access', **params)
|
977
1035
|
end
|
978
1036
|
|
979
1037
|
# Sets the guest access settings for a room
|
@@ -989,7 +1047,7 @@ module MatrixSdk::Protocols::CS
|
|
989
1047
|
guest_access: guest_access
|
990
1048
|
}
|
991
1049
|
|
992
|
-
send_state_event(room_id, 'm.room.guest_access', content, params)
|
1050
|
+
send_state_event(room_id, 'm.room.guest_access', content, **params)
|
993
1051
|
end
|
994
1052
|
|
995
1053
|
# Gets the creation configuration object for a room
|
@@ -1001,7 +1059,7 @@ module MatrixSdk::Protocols::CS
|
|
1001
1059
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-create
|
1002
1060
|
# The Matrix Spec, for more information about the event and data
|
1003
1061
|
def get_room_creation_info(room_id, **params)
|
1004
|
-
get_room_state(room_id, 'm.room.create', params)
|
1062
|
+
get_room_state(room_id, 'm.room.create', **params)
|
1005
1063
|
end
|
1006
1064
|
|
1007
1065
|
# Gets the encryption configuration for a room
|
@@ -1013,7 +1071,7 @@ module MatrixSdk::Protocols::CS
|
|
1013
1071
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-encryption
|
1014
1072
|
# The Matrix Spec, for more information about the event and data
|
1015
1073
|
def get_room_encryption_settings(room_id, **params)
|
1016
|
-
get_room_state(room_id, 'm.room.encryption', params)
|
1074
|
+
get_room_state(room_id, 'm.room.encryption', **params)
|
1017
1075
|
end
|
1018
1076
|
|
1019
1077
|
# Sets the encryption configuration for a room
|
@@ -1032,7 +1090,7 @@ module MatrixSdk::Protocols::CS
|
|
1032
1090
|
rotation_period_ms: rotation_period_ms,
|
1033
1091
|
rotation_period_msgs: rotation_period_msgs
|
1034
1092
|
}
|
1035
|
-
send_state_event(room_id, 'm.room.encryption', content, params)
|
1093
|
+
send_state_event(room_id, 'm.room.encryption', content, **params)
|
1036
1094
|
end
|
1037
1095
|
|
1038
1096
|
# Gets the history availabiilty for a room
|
@@ -1044,7 +1102,7 @@ module MatrixSdk::Protocols::CS
|
|
1044
1102
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-history-visibility
|
1045
1103
|
# The Matrix Spec, for more information about the event and data
|
1046
1104
|
def get_room_history_visibility(room_id, **params)
|
1047
|
-
get_room_state(room_id, 'm.room.history_visibility', params)
|
1105
|
+
get_room_state(room_id, 'm.room.history_visibility', **params)
|
1048
1106
|
end
|
1049
1107
|
|
1050
1108
|
# Sets the history availability for a room
|
@@ -1060,7 +1118,7 @@ module MatrixSdk::Protocols::CS
|
|
1060
1118
|
history_visibility: visibility
|
1061
1119
|
}
|
1062
1120
|
|
1063
|
-
send_state_event(room_id, 'm.room.history_visibility', content, params)
|
1121
|
+
send_state_event(room_id, 'm.room.history_visibility', content, **params)
|
1064
1122
|
end
|
1065
1123
|
|
1066
1124
|
# Gets the server ACLs for a room
|
@@ -1072,7 +1130,7 @@ module MatrixSdk::Protocols::CS
|
|
1072
1130
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-server-acl
|
1073
1131
|
# The Matrix Spec, for more information about the event and data
|
1074
1132
|
def get_room_server_acl(room_id, **params)
|
1075
|
-
get_room_state(room_id, 'm.room.server_acl', params)
|
1133
|
+
get_room_state(room_id, 'm.room.server_acl', **params)
|
1076
1134
|
end
|
1077
1135
|
|
1078
1136
|
# Sets the server ACL configuration for a room
|
@@ -1085,14 +1143,14 @@ module MatrixSdk::Protocols::CS
|
|
1085
1143
|
# @return [Response] The resulting state event
|
1086
1144
|
# @see https://matrix.org/docs/spec/client_server/latest.html#m-room-guest-server-acl
|
1087
1145
|
# The Matrix Spec, for more information about the event and data
|
1088
|
-
def set_room_server_acl(room_id, allow_ip_literals: false,
|
1146
|
+
def set_room_server_acl(room_id, allow:, deny:, allow_ip_literals: false, **params)
|
1089
1147
|
content = {
|
1090
1148
|
allow_ip_literals: allow_ip_literals,
|
1091
1149
|
allow: allow,
|
1092
1150
|
deny: deny
|
1093
1151
|
}
|
1094
1152
|
|
1095
|
-
send_state_event(room_id, 'm.room.server_acl', content, params)
|
1153
|
+
send_state_event(room_id, 'm.room.server_acl', content, **params)
|
1096
1154
|
end
|
1097
1155
|
|
1098
1156
|
def leave_room(room_id, **params)
|
@@ -1101,7 +1159,7 @@ module MatrixSdk::Protocols::CS
|
|
1101
1159
|
|
1102
1160
|
room_id = ERB::Util.url_encode room_id.to_s
|
1103
1161
|
|
1104
|
-
request(:post,
|
1162
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/leave", query: query)
|
1105
1163
|
end
|
1106
1164
|
|
1107
1165
|
def forget_room(room_id, **params)
|
@@ -1110,7 +1168,7 @@ module MatrixSdk::Protocols::CS
|
|
1110
1168
|
|
1111
1169
|
room_id = ERB::Util.url_encode room_id.to_s
|
1112
1170
|
|
1113
|
-
request(:post,
|
1171
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/forget", query: query)
|
1114
1172
|
end
|
1115
1173
|
|
1116
1174
|
# Directly joins a room by ID
|
@@ -1130,7 +1188,7 @@ module MatrixSdk::Protocols::CS
|
|
1130
1188
|
|
1131
1189
|
room_id = ERB::Util.url_encode room_id.to_s
|
1132
1190
|
|
1133
|
-
request(:post,
|
1191
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/join", body: body, query: query)
|
1134
1192
|
end
|
1135
1193
|
|
1136
1194
|
def invite_user(room_id, user_id, **params)
|
@@ -1143,7 +1201,7 @@ module MatrixSdk::Protocols::CS
|
|
1143
1201
|
|
1144
1202
|
room_id = ERB::Util.url_encode room_id.to_s
|
1145
1203
|
|
1146
|
-
request(:post,
|
1204
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/invite", body: content, query: query)
|
1147
1205
|
end
|
1148
1206
|
|
1149
1207
|
def kick_user(room_id, user_id, reason: '', **params)
|
@@ -1156,7 +1214,7 @@ module MatrixSdk::Protocols::CS
|
|
1156
1214
|
}
|
1157
1215
|
room_id = ERB::Util.url_encode room_id.to_s
|
1158
1216
|
|
1159
|
-
request(:post,
|
1217
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/kick", body: content, query: query)
|
1160
1218
|
end
|
1161
1219
|
|
1162
1220
|
def get_membership(room_id, user_id, **params)
|
@@ -1166,7 +1224,7 @@ module MatrixSdk::Protocols::CS
|
|
1166
1224
|
room_id = ERB::Util.url_encode room_id.to_s
|
1167
1225
|
user_id = ERB::Util.url_encode user_id.to_s
|
1168
1226
|
|
1169
|
-
request(:get,
|
1227
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/state/m.room.member/#{user_id}", query: query)
|
1170
1228
|
end
|
1171
1229
|
|
1172
1230
|
def set_membership(room_id, user_id, membership, reason: '', **params)
|
@@ -1190,7 +1248,7 @@ module MatrixSdk::Protocols::CS
|
|
1190
1248
|
}
|
1191
1249
|
room_id = ERB::Util.url_encode room_id.to_s
|
1192
1250
|
|
1193
|
-
request(:post,
|
1251
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/ban", body: content, query: query)
|
1194
1252
|
end
|
1195
1253
|
|
1196
1254
|
def unban_user(room_id, user_id, **params)
|
@@ -1202,7 +1260,7 @@ module MatrixSdk::Protocols::CS
|
|
1202
1260
|
}
|
1203
1261
|
room_id = ERB::Util.url_encode room_id.to_s
|
1204
1262
|
|
1205
|
-
request(:post,
|
1263
|
+
request(:post, client_api_latest, "/rooms/#{room_id}/unban", body: content, query: query)
|
1206
1264
|
end
|
1207
1265
|
|
1208
1266
|
# Gets the room directory visibility status for a room
|
@@ -1217,7 +1275,7 @@ module MatrixSdk::Protocols::CS
|
|
1217
1275
|
|
1218
1276
|
room_id = ERB::Util.url_encode room_id.to_s
|
1219
1277
|
|
1220
|
-
request(:get,
|
1278
|
+
request(:get, client_api_latest, "/directory/list/room/#{room_id}", query: query)
|
1221
1279
|
end
|
1222
1280
|
|
1223
1281
|
# Sets the room directory visibility status for a room
|
@@ -1237,7 +1295,7 @@ module MatrixSdk::Protocols::CS
|
|
1237
1295
|
|
1238
1296
|
room_id = ERB::Util.url_encode room_id.to_s
|
1239
1297
|
|
1240
|
-
request(:put,
|
1298
|
+
request(:put, client_api_latest, "/directory/list/room/#{room_id}", body: body, query: query)
|
1241
1299
|
end
|
1242
1300
|
|
1243
1301
|
def get_user_tags(user_id, room_id, **params)
|
@@ -1247,7 +1305,7 @@ module MatrixSdk::Protocols::CS
|
|
1247
1305
|
room_id = ERB::Util.url_encode room_id.to_s
|
1248
1306
|
user_id = ERB::Util.url_encode user_id.to_s
|
1249
1307
|
|
1250
|
-
request(:get,
|
1308
|
+
request(:get, client_api_latest, "/user/#{user_id}/rooms/#{room_id}/tags", query: query)
|
1251
1309
|
end
|
1252
1310
|
|
1253
1311
|
def remove_user_tag(user_id, room_id, tag, **params)
|
@@ -1258,7 +1316,7 @@ module MatrixSdk::Protocols::CS
|
|
1258
1316
|
user_id = ERB::Util.url_encode user_id.to_s
|
1259
1317
|
tag = ERB::Util.url_encode tag.to_s
|
1260
1318
|
|
1261
|
-
request(:delete,
|
1319
|
+
request(:delete, client_api_latest, "/user/#{user_id}/rooms/#{room_id}/tags/#{tag}", query: query)
|
1262
1320
|
end
|
1263
1321
|
|
1264
1322
|
def add_user_tag(user_id, room_id, tag, **params)
|
@@ -1276,7 +1334,7 @@ module MatrixSdk::Protocols::CS
|
|
1276
1334
|
user_id = ERB::Util.url_encode user_id.to_s
|
1277
1335
|
tag = ERB::Util.url_encode tag.to_s
|
1278
1336
|
|
1279
|
-
request(:put,
|
1337
|
+
request(:put, client_api_latest, "/user/#{user_id}/rooms/#{room_id}/tags/#{tag}", body: content, query: query)
|
1280
1338
|
end
|
1281
1339
|
|
1282
1340
|
def get_account_data(user_id, type_key, **params)
|
@@ -1286,7 +1344,7 @@ module MatrixSdk::Protocols::CS
|
|
1286
1344
|
user_id = ERB::Util.url_encode user_id.to_s
|
1287
1345
|
type_key = ERB::Util.url_encode type_key.to_s
|
1288
1346
|
|
1289
|
-
request(:get,
|
1347
|
+
request(:get, client_api_latest, "/user/#{user_id}/account_data/#{type_key}", query: query)
|
1290
1348
|
end
|
1291
1349
|
|
1292
1350
|
def set_account_data(user_id, type_key, account_data, **params)
|
@@ -1296,7 +1354,7 @@ module MatrixSdk::Protocols::CS
|
|
1296
1354
|
user_id = ERB::Util.url_encode user_id.to_s
|
1297
1355
|
type_key = ERB::Util.url_encode type_key.to_s
|
1298
1356
|
|
1299
|
-
request(:put,
|
1357
|
+
request(:put, client_api_latest, "/user/#{user_id}/account_data/#{type_key}", body: account_data, query: query)
|
1300
1358
|
end
|
1301
1359
|
|
1302
1360
|
def get_room_account_data(user_id, room_id, type_key, **params)
|
@@ -1307,7 +1365,7 @@ module MatrixSdk::Protocols::CS
|
|
1307
1365
|
room_id = ERB::Util.url_encode room_id.to_s
|
1308
1366
|
type_key = ERB::Util.url_encode type_key.to_s
|
1309
1367
|
|
1310
|
-
request(:get,
|
1368
|
+
request(:get, client_api_latest, "/user/#{user_id}/rooms/#{room_id}/account_data/#{type_key}", query: query)
|
1311
1369
|
end
|
1312
1370
|
|
1313
1371
|
def set_room_account_data(user_id, room_id, type_key, account_data, **params)
|
@@ -1318,7 +1376,7 @@ module MatrixSdk::Protocols::CS
|
|
1318
1376
|
room_id = ERB::Util.url_encode room_id.to_s
|
1319
1377
|
type_key = ERB::Util.url_encode type_key.to_s
|
1320
1378
|
|
1321
|
-
request(:put,
|
1379
|
+
request(:put, client_api_latest, "/user/#{user_id}/rooms/#{room_id}/account_data/#{type_key}", body: account_data, query: query)
|
1322
1380
|
end
|
1323
1381
|
|
1324
1382
|
# Retrieve user information
|
@@ -1330,7 +1388,7 @@ module MatrixSdk::Protocols::CS
|
|
1330
1388
|
def whois(user_id)
|
1331
1389
|
user_id = ERB::Util.url_encode user_id.to_s
|
1332
1390
|
|
1333
|
-
request(:get,
|
1391
|
+
request(:get, client_api_latest, "/admin/whois/#{user_id}")
|
1334
1392
|
end
|
1335
1393
|
|
1336
1394
|
def get_filter(user_id, filter_id, **params)
|
@@ -1340,7 +1398,7 @@ module MatrixSdk::Protocols::CS
|
|
1340
1398
|
user_id = ERB::Util.url_encode user_id.to_s
|
1341
1399
|
filter_id = ERB::Util.url_encode filter_id.to_s
|
1342
1400
|
|
1343
|
-
request(:get,
|
1401
|
+
request(:get, client_api_latest, "/user/#{user_id}/filter/#{filter_id}", query: query)
|
1344
1402
|
end
|
1345
1403
|
|
1346
1404
|
# Creates a filter for future use
|
@@ -1353,7 +1411,7 @@ module MatrixSdk::Protocols::CS
|
|
1353
1411
|
|
1354
1412
|
user_id = ERB::Util.url_encode user_id.to_s
|
1355
1413
|
|
1356
|
-
request(:post,
|
1414
|
+
request(:post, client_api_latest, "/user/#{user_id}/filter", body: filter_params, query: query)
|
1357
1415
|
end
|
1358
1416
|
|
1359
1417
|
def media_upload(content, content_type, **params)
|
@@ -1369,7 +1427,7 @@ module MatrixSdk::Protocols::CS
|
|
1369
1427
|
|
1370
1428
|
user_id = ERB::Util.url_encode user_id.to_s
|
1371
1429
|
|
1372
|
-
request(:get,
|
1430
|
+
request(:get, client_api_latest, "/profile/#{user_id}/displayname", query: query)
|
1373
1431
|
end
|
1374
1432
|
|
1375
1433
|
def set_display_name(user_id, display_name, **params)
|
@@ -1382,7 +1440,7 @@ module MatrixSdk::Protocols::CS
|
|
1382
1440
|
|
1383
1441
|
user_id = ERB::Util.url_encode user_id.to_s
|
1384
1442
|
|
1385
|
-
request(:put,
|
1443
|
+
request(:put, client_api_latest, "/profile/#{user_id}/displayname", body: content, query: query)
|
1386
1444
|
end
|
1387
1445
|
|
1388
1446
|
def get_avatar_url(user_id, **params)
|
@@ -1391,7 +1449,7 @@ module MatrixSdk::Protocols::CS
|
|
1391
1449
|
|
1392
1450
|
user_id = ERB::Util.url_encode user_id.to_s
|
1393
1451
|
|
1394
|
-
request(:get,
|
1452
|
+
request(:get, client_api_latest, "/profile/#{user_id}/avatar_url", query: query)
|
1395
1453
|
end
|
1396
1454
|
|
1397
1455
|
# Sets the avatar URL for a user
|
@@ -1411,7 +1469,7 @@ module MatrixSdk::Protocols::CS
|
|
1411
1469
|
# api.set_avatar_url(api.whoami?[:user_id], mxc)
|
1412
1470
|
#
|
1413
1471
|
# @param [String,MXID] user_id The ID of the user to set the avatar for
|
1414
|
-
# @param [String,URI::
|
1472
|
+
# @param [String,URI::MXC] url The new avatar URL, should be a mxc:// URL
|
1415
1473
|
# @return [Response] An empty response hash if the change was successful
|
1416
1474
|
# @see https://matrix.org/docs/spec/client_server/latest#put-matrix-client-r0-profile-userid-avatar-url
|
1417
1475
|
# The Matrix Spec, for more information about the event and data
|
@@ -1425,7 +1483,7 @@ module MatrixSdk::Protocols::CS
|
|
1425
1483
|
|
1426
1484
|
user_id = ERB::Util.url_encode user_id.to_s
|
1427
1485
|
|
1428
|
-
request(:put,
|
1486
|
+
request(:put, client_api_latest, "/profile/#{user_id}/avatar_url", body: content, query: query)
|
1429
1487
|
end
|
1430
1488
|
|
1431
1489
|
# Gets the combined profile object of a user.
|
@@ -1442,7 +1500,7 @@ module MatrixSdk::Protocols::CS
|
|
1442
1500
|
|
1443
1501
|
user_id = ERB::Util.url_encode user_id.to_s
|
1444
1502
|
|
1445
|
-
request(:get,
|
1503
|
+
request(:get, client_api_latest, "/profile/#{user_id}", query: query)
|
1446
1504
|
end
|
1447
1505
|
|
1448
1506
|
# Gets TURN server connection information and credentials
|
@@ -1451,7 +1509,7 @@ module MatrixSdk::Protocols::CS
|
|
1451
1509
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-voip-turnserver
|
1452
1510
|
# The Matrix Spec, for more information about the event and data
|
1453
1511
|
def get_turn_server
|
1454
|
-
request(:get,
|
1512
|
+
request(:get, client_api_latest, '/voip/turnServer')
|
1455
1513
|
end
|
1456
1514
|
|
1457
1515
|
# Sets the typing status for a user
|
@@ -1472,7 +1530,7 @@ module MatrixSdk::Protocols::CS
|
|
1472
1530
|
timeout: timeout ? timeout * 1000 : nil
|
1473
1531
|
}.compact
|
1474
1532
|
|
1475
|
-
request(:put,
|
1533
|
+
request(:put, client_api_latest, "/rooms/#{room_id}/typing/#{user_id}", body: body)
|
1476
1534
|
end
|
1477
1535
|
|
1478
1536
|
# Gets the presence status of a user
|
@@ -1484,7 +1542,7 @@ module MatrixSdk::Protocols::CS
|
|
1484
1542
|
def get_presence_status(user_id)
|
1485
1543
|
user_id = ERB::Util.url_encode user_id.to_s
|
1486
1544
|
|
1487
|
-
request(:get,
|
1545
|
+
request(:get, client_api_latest, "/presence/#{user_id}/status")
|
1488
1546
|
end
|
1489
1547
|
|
1490
1548
|
# Sets the presence status of a user
|
@@ -1504,7 +1562,7 @@ module MatrixSdk::Protocols::CS
|
|
1504
1562
|
status_msg: message
|
1505
1563
|
}.compact
|
1506
1564
|
|
1507
|
-
request(:put,
|
1565
|
+
request(:put, client_api_latest, "/presence/#{user_id}/status", body: body)
|
1508
1566
|
end
|
1509
1567
|
|
1510
1568
|
# Converts a Matrix content URL (mxc://) to a media download URL
|
@@ -1521,7 +1579,7 @@ module MatrixSdk::Protocols::CS
|
|
1521
1579
|
# # => #<URI::HTTPS https://matrix.org/_matrix/media/r0/download/example.com/media_hash>
|
1522
1580
|
def get_download_url(mxcurl, source: nil, **_params)
|
1523
1581
|
mxcurl = URI.parse(mxcurl.to_s) unless mxcurl.is_a? URI
|
1524
|
-
raise 'Not a mxc:// URL' unless mxcurl.is_a? URI::
|
1582
|
+
raise 'Not a mxc:// URL' unless mxcurl.is_a? URI::MXC
|
1525
1583
|
|
1526
1584
|
if source
|
1527
1585
|
source = "https://#{source}" unless source.include? '://'
|
@@ -1581,7 +1639,7 @@ module MatrixSdk::Protocols::CS
|
|
1581
1639
|
messages: messages
|
1582
1640
|
}.compact
|
1583
1641
|
|
1584
|
-
request(:put,
|
1642
|
+
request(:put, client_api_latest, "/sendToDevice/#{event_type}/#{txn_id}", body: body)
|
1585
1643
|
end
|
1586
1644
|
|
1587
1645
|
# Gets the room ID for an alias
|
@@ -1594,7 +1652,7 @@ module MatrixSdk::Protocols::CS
|
|
1594
1652
|
|
1595
1653
|
room_alias = ERB::Util.url_encode room_alias.to_s
|
1596
1654
|
|
1597
|
-
request(:get,
|
1655
|
+
request(:get, client_api_latest, "/directory/room/#{room_alias}", query: query)
|
1598
1656
|
end
|
1599
1657
|
|
1600
1658
|
# Sets the room ID for an alias
|
@@ -1611,7 +1669,7 @@ module MatrixSdk::Protocols::CS
|
|
1611
1669
|
}
|
1612
1670
|
room_alias = ERB::Util.url_encode room_alias.to_s
|
1613
1671
|
|
1614
|
-
request(:put,
|
1672
|
+
request(:put, client_api_latest, "/directory/room/#{room_alias}", body: content, query: query)
|
1615
1673
|
end
|
1616
1674
|
|
1617
1675
|
# Remove an alias from its room
|
@@ -1623,7 +1681,7 @@ module MatrixSdk::Protocols::CS
|
|
1623
1681
|
|
1624
1682
|
room_alias = ERB::Util.url_encode room_alias.to_s
|
1625
1683
|
|
1626
|
-
request(:delete,
|
1684
|
+
request(:delete, client_api_latest, "/directory/room/#{room_alias}", query: query)
|
1627
1685
|
end
|
1628
1686
|
|
1629
1687
|
# Gets a list of all the members in a room
|
@@ -1637,7 +1695,7 @@ module MatrixSdk::Protocols::CS
|
|
1637
1695
|
|
1638
1696
|
room_id = ERB::Util.url_encode room_id.to_s
|
1639
1697
|
|
1640
|
-
request(:get,
|
1698
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/members", query: query.merge(params))
|
1641
1699
|
end
|
1642
1700
|
|
1643
1701
|
# Gets a list of the joined members in a room
|
@@ -1652,7 +1710,7 @@ module MatrixSdk::Protocols::CS
|
|
1652
1710
|
|
1653
1711
|
room_id = ERB::Util.url_encode room_id.to_s
|
1654
1712
|
|
1655
|
-
request(:get,
|
1713
|
+
request(:get, client_api_latest, "/rooms/#{room_id}/joined_members", query: query)
|
1656
1714
|
end
|
1657
1715
|
|
1658
1716
|
# Gets a list of the current users registered devices
|
@@ -1660,7 +1718,7 @@ module MatrixSdk::Protocols::CS
|
|
1660
1718
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices
|
1661
1719
|
# The Matrix Spec, for more information about the data
|
1662
1720
|
def get_devices
|
1663
|
-
request(:get,
|
1721
|
+
request(:get, client_api_latest, '/devices')
|
1664
1722
|
end
|
1665
1723
|
|
1666
1724
|
# Gets the information about a certain client device
|
@@ -1671,7 +1729,7 @@ module MatrixSdk::Protocols::CS
|
|
1671
1729
|
def get_device(device_id)
|
1672
1730
|
device_id = ERB::Util.url_encode device_id.to_s
|
1673
1731
|
|
1674
|
-
request(:get,
|
1732
|
+
request(:get, client_api_latest, "/devices/#{device_id}")
|
1675
1733
|
end
|
1676
1734
|
|
1677
1735
|
# Sets the metadata for a device
|
@@ -1682,7 +1740,7 @@ module MatrixSdk::Protocols::CS
|
|
1682
1740
|
def set_device(device_id, display_name:)
|
1683
1741
|
device_id = ERB::Util.url_encode device_id.to_s
|
1684
1742
|
|
1685
|
-
request(:put,
|
1743
|
+
request(:put, client_api_latest, "/devices/#{device_id}", body: { display_name: display_name })
|
1686
1744
|
end
|
1687
1745
|
|
1688
1746
|
# Removes a device from the current user
|
@@ -1695,7 +1753,7 @@ module MatrixSdk::Protocols::CS
|
|
1695
1753
|
def delete_device(device_id, auth:)
|
1696
1754
|
device_id = ERB::Util.url_encode device_id.to_s
|
1697
1755
|
|
1698
|
-
request(:delete,
|
1756
|
+
request(:delete, client_api_latest, "/devices/#{device_id}", body: { auth: auth })
|
1699
1757
|
end
|
1700
1758
|
|
1701
1759
|
# Run a query for device keys
|
@@ -1712,7 +1770,7 @@ module MatrixSdk::Protocols::CS
|
|
1712
1770
|
# # => { :device_keys => { :'@alice:example.com' => { :ABCDEFGHIJ => { ...
|
1713
1771
|
# @see https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-keys-query
|
1714
1772
|
# The Matrix Spec, for more information about the parameters and data
|
1715
|
-
def keys_query(timeout: nil,
|
1773
|
+
def keys_query(device_keys:, timeout: nil, token: nil, **params)
|
1716
1774
|
body = {
|
1717
1775
|
timeout: (timeout || 10) * 1000,
|
1718
1776
|
device_keys: device_keys
|
@@ -1720,7 +1778,7 @@ module MatrixSdk::Protocols::CS
|
|
1720
1778
|
body[:timeout] = params[:timeout_ms] if params.key? :timeout_ms
|
1721
1779
|
body[:token] = token if token
|
1722
1780
|
|
1723
|
-
request(:post,
|
1781
|
+
request(:post, client_api_latest, '/keys/query', body: body)
|
1724
1782
|
end
|
1725
1783
|
|
1726
1784
|
# Claim one-time keys for pre-key messaging
|
@@ -1735,7 +1793,7 @@ module MatrixSdk::Protocols::CS
|
|
1735
1793
|
one_time_keys: one_time_keys,
|
1736
1794
|
timeout: timeout * 1000
|
1737
1795
|
}
|
1738
|
-
request(:post,
|
1796
|
+
request(:post, client_api_latest, '/keys/claim', body: body)
|
1739
1797
|
end
|
1740
1798
|
|
1741
1799
|
# Retrieve device key changes between two sync requests
|
@@ -1751,7 +1809,7 @@ module MatrixSdk::Protocols::CS
|
|
1751
1809
|
to: to
|
1752
1810
|
}
|
1753
1811
|
|
1754
|
-
request(:get,
|
1812
|
+
request(:get, client_api_latest, '/keys/changes', query: query)
|
1755
1813
|
end
|
1756
1814
|
|
1757
1815
|
# Gets the list of registered pushers for the current user
|
@@ -1760,7 +1818,7 @@ module MatrixSdk::Protocols::CS
|
|
1760
1818
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers
|
1761
1819
|
# The Matrix Spec, for more information about the parameters and data
|
1762
1820
|
def get_pushers
|
1763
|
-
request(:get,
|
1821
|
+
request(:get, client_api_latest, '/pushers')
|
1764
1822
|
end
|
1765
1823
|
|
1766
1824
|
# rubocop:disable Metrics/ParameterLists
|
@@ -1793,7 +1851,7 @@ module MatrixSdk::Protocols::CS
|
|
1793
1851
|
append: params[:append]
|
1794
1852
|
}.compact
|
1795
1853
|
|
1796
|
-
request(:post,
|
1854
|
+
request(:post, client_api_latest, '/pushers/set', body: body)
|
1797
1855
|
end
|
1798
1856
|
# rubocop:enable Metrics/ParameterLists
|
1799
1857
|
|
@@ -1814,7 +1872,7 @@ module MatrixSdk::Protocols::CS
|
|
1814
1872
|
only: only
|
1815
1873
|
}.compact
|
1816
1874
|
|
1817
|
-
request(:get,
|
1875
|
+
request(:get, client_api_latest, '/notifications', query: query)
|
1818
1876
|
end
|
1819
1877
|
|
1820
1878
|
# Retrieves the full list of registered push rules for the current user
|
@@ -1823,7 +1881,7 @@ module MatrixSdk::Protocols::CS
|
|
1823
1881
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushrules
|
1824
1882
|
# The Matrix Spec, for more information about the parameters and data
|
1825
1883
|
def get_pushrules
|
1826
|
-
request(:get,
|
1884
|
+
request(:get, client_api_latest, '/pushrules/')
|
1827
1885
|
end
|
1828
1886
|
|
1829
1887
|
# Retrieves a single registered push rule for the current user
|
@@ -1834,12 +1892,12 @@ module MatrixSdk::Protocols::CS
|
|
1834
1892
|
# @return [Response] A response hash containing the full data of the requested push rule
|
1835
1893
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushrules-scope-kind-ruleid
|
1836
1894
|
# The Matrix Spec, for more information about the parameters and data
|
1837
|
-
def get_pushrule(scope: 'global'
|
1895
|
+
def get_pushrule(kind:, id:, scope: 'global')
|
1838
1896
|
scope = ERB::Util.url_encode scope.to_s
|
1839
1897
|
kind = ERB::Util.url_encode kind.to_s
|
1840
1898
|
id = ERB::Util.url_encode id.to_s
|
1841
1899
|
|
1842
|
-
request(:get,
|
1900
|
+
request(:get, client_api_latest, "/pushrules/#{scope}/#{kind}/#{id}")
|
1843
1901
|
end
|
1844
1902
|
|
1845
1903
|
# Checks if a push rule for the current user is enabled
|
@@ -1850,12 +1908,12 @@ module MatrixSdk::Protocols::CS
|
|
1850
1908
|
# @return [Response] A response hash containing an :enabled key for if the rule is enabled or not
|
1851
1909
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushrules-scope-kind-ruleid-enabled
|
1852
1910
|
# The Matrix Spec, for more information about the parameters and data
|
1853
|
-
def get_pushrule_enabled(scope: 'global'
|
1911
|
+
def get_pushrule_enabled(kind:, id:, scope: 'global')
|
1854
1912
|
scope = ERB::Util.url_encode scope.to_s
|
1855
1913
|
kind = ERB::Util.url_encode kind.to_s
|
1856
1914
|
id = ERB::Util.url_encode id.to_s
|
1857
1915
|
|
1858
|
-
request(:get,
|
1916
|
+
request(:get, client_api_latest, "/pushrules/#{scope}/#{kind}/#{id}/enabled")
|
1859
1917
|
end
|
1860
1918
|
|
1861
1919
|
# Enabled/Disables a specific push rule for the current user
|
@@ -1867,7 +1925,7 @@ module MatrixSdk::Protocols::CS
|
|
1867
1925
|
# @return [Response] An empty response hash if the push rule was enabled/disabled successfully
|
1868
1926
|
# @see https://matrix.org/docs/spec/client_server/latest#put-matrix-client-r0-pushrules-scope-kind-ruleid-enabled
|
1869
1927
|
# The Matrix Spec, for more information about the parameters and data
|
1870
|
-
def set_pushrule_enabled(enabled, scope: 'global'
|
1928
|
+
def set_pushrule_enabled(enabled, kind:, id:, scope: 'global')
|
1871
1929
|
scope = ERB::Util.url_encode scope.to_s
|
1872
1930
|
kind = ERB::Util.url_encode kind.to_s
|
1873
1931
|
id = ERB::Util.url_encode id.to_s
|
@@ -1876,7 +1934,7 @@ module MatrixSdk::Protocols::CS
|
|
1876
1934
|
enabled: enabled
|
1877
1935
|
}
|
1878
1936
|
|
1879
|
-
request(:put,
|
1937
|
+
request(:put, client_api_latest, "/pushrules/#{scope}/#{kind}/#{id}/enabled", body: body)
|
1880
1938
|
end
|
1881
1939
|
|
1882
1940
|
# Gets the current list of actions for a specific push rule for the current user
|
@@ -1887,12 +1945,12 @@ module MatrixSdk::Protocols::CS
|
|
1887
1945
|
# @return [Response] A response hash containing an :enabled key for if the rule is enabled or not
|
1888
1946
|
# @see https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushrules-scope-kind-ruleid-actions
|
1889
1947
|
# The Matrix Spec, for more information about the parameters and data
|
1890
|
-
def get_pushrule_actions(scope: 'global'
|
1948
|
+
def get_pushrule_actions(kind:, id:, scope: 'global')
|
1891
1949
|
scope = ERB::Util.url_encode scope.to_s
|
1892
1950
|
kind = ERB::Util.url_encode kind.to_s
|
1893
1951
|
id = ERB::Util.url_encode id.to_s
|
1894
1952
|
|
1895
|
-
request(:get,
|
1953
|
+
request(:get, client_api_latest, "/pushrules/#{scope}/#{kind}/#{id}/actions")
|
1896
1954
|
end
|
1897
1955
|
|
1898
1956
|
# Replaces the list of actions for a push rule for the current user
|
@@ -1904,7 +1962,7 @@ module MatrixSdk::Protocols::CS
|
|
1904
1962
|
# @return [Response] An empty response hash if the push rule actions were modified successfully
|
1905
1963
|
# @see https://matrix.org/docs/spec/client_server/latest#put-matrix-client-r0-pushrules-scope-kind-ruleid-actions
|
1906
1964
|
# The Matrix Spec, for more information about the parameters and data
|
1907
|
-
def set_pushrule_actions(actions, scope: 'global'
|
1965
|
+
def set_pushrule_actions(actions, kind:, id:, scope: 'global')
|
1908
1966
|
scope = ERB::Util.url_encode scope.to_s
|
1909
1967
|
kind = ERB::Util.url_encode kind.to_s
|
1910
1968
|
id = ERB::Util.url_encode id.to_s
|
@@ -1915,7 +1973,7 @@ module MatrixSdk::Protocols::CS
|
|
1915
1973
|
actions: actions
|
1916
1974
|
}
|
1917
1975
|
|
1918
|
-
request(:put,
|
1976
|
+
request(:put, client_api_latest, "/pushrules/#{scope}/#{kind}/#{id}/actions", body: body)
|
1919
1977
|
end
|
1920
1978
|
|
1921
1979
|
# Gets the MXID of the currently logged-in user
|
@@ -1924,7 +1982,7 @@ module MatrixSdk::Protocols::CS
|
|
1924
1982
|
query = {}
|
1925
1983
|
query[:user_id] = params.delete(:user_id) if protocol?(:AS) && params.key?(:user_id)
|
1926
1984
|
|
1927
|
-
request(:get,
|
1985
|
+
request(:get, client_api_latest, '/account/whoami', query: query)
|
1928
1986
|
end
|
1929
1987
|
end
|
1930
1988
|
# rubocop:enable Metrics/ModuleLength
|