aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2021-03-28 19:14:56 -0300
committerMatias Linares <matiaslina@gmail.com>2021-03-28 19:17:30 -0300
commitf3f846be62f3715ad2a716043c8e92806c2472fa (patch)
tree20761f1c0db6cf6b05c9944ec239f3f8711e831d
parentf6397392c4fc88d1e9335bbbc4f91d8cb2f29368 (diff)
downloadperl6-matrix-client-f3f846be62f3715ad2a716043c8e92806c2472fa.tar.gz
Add read-markers api support
-rw-r--r--docs/Matrix/Client/Room.rakudoc10
-rw-r--r--endpoints.md4
-rw-r--r--lib/Matrix/Client/Room.rakumod15
-rw-r--r--t/30-room.t9
4 files changed, 34 insertions, 4 deletions
diff --git a/docs/Matrix/Client/Room.rakudoc b/docs/Matrix/Client/Room.rakudoc
index f186583..7d4cdff 100644
--- a/docs/Matrix/Client/Room.rakudoc
+++ b/docs/Matrix/Client/Room.rakudoc
@@ -128,6 +128,16 @@ server.
It will return the C<event_id> for this state change.
+=head2 read-marker
+
+ method read-marker(Str:D $fully-read, Str $read?)
+
+Sets the position of the read marker for this room, and optionally the
+read receipt's location.
+
+The C<$fully-read> and C<$read> parameters are event ids where the
+markers will be placed.
+
=head2 invite
method invite(Str $user-id)
diff --git a/endpoints.md b/endpoints.md
index e8bc9f8..e170ca1 100644
--- a/endpoints.md
+++ b/endpoints.md
@@ -61,7 +61,7 @@ from matrix.org. This will give you an overview about what's implemented in the
## Read Markers
-- [ ] POST - /_matrix/client/r0/rooms/{roomId}/read_markers
+- [X] POST - /_matrix/client/r0/rooms/{roomId}/read_markers
## Reporting content
@@ -176,4 +176,4 @@ from matrix.org. This will give you an overview about what's implemented in the
# Endpoint completion
-0.446602% - (46/103)
+0.456311% - (47/103)
diff --git a/lib/Matrix/Client/Room.rakumod b/lib/Matrix/Client/Room.rakumod
index 1e8c582..34c73ae 100644
--- a/lib/Matrix/Client/Room.rakumod
+++ b/lib/Matrix/Client/Room.rakumod
@@ -6,7 +6,7 @@ use Matrix::Client::Response;
unit class Matrix::Client::Room does Matrix::Client::Requester;
has $!name;
-has $.id;
+has $.id is required;
submethod TWEAK {
$!url-prefix = "/rooms/$!id";
@@ -142,6 +142,19 @@ method send-state(Str:D $event-type, :$state-key = "", *%args --> Str) {
from-json($res.content)<event_id>
}
+#| POST - /_matrix/client/r0/rooms/{roomId}/read_markers
+method read-marker(Str:D $fully-read, Str $read?) {
+ my %data = %(
+ "m.fully_read" => $fully-read
+ );
+
+ %data<m.read> = $read with $read;
+
+ $.post('/read_markers', |%data);
+}
+
+method typing()
+
# Room membership!
## Joining rooms
diff --git a/t/30-room.t b/t/30-room.t
index 9cec207..b9f7cfd 100644
--- a/t/30-room.t
+++ b/t/30-room.t
@@ -1,7 +1,14 @@
use lib 'lib';
use Test;
use Matrix::Client;
-plan 10;
+plan 12;
+
+use-ok 'Matrix::Client::Room';
+
+my $room = Matrix::Client::Room.new(:home-server<test>, :id<!something>);
+can-ok $room, 'read-marker';
+
+# Integrations tests;
unless %*ENV<MATRIX_CLIENT_TEST_SERVER> {
skip-rest 'No test server setted';