aboutsummaryrefslogtreecommitdiff
path: root/lib/Matrix/Client
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2020-12-27 11:53:50 -0300
committerMatias Linares <matiaslina@gmail.com>2020-12-27 11:53:50 -0300
commit2983d424bad511d5c50c52caf5daedff27eb2ada (patch)
treee452b23ae59da46f348cd9ef2ad9ccb21f2230b4 /lib/Matrix/Client
parentd5b3361c9ceeac3ed3a90dab35b12b0bd4ab7612 (diff)
downloadperl6-matrix-client-2983d424bad511d5c50c52caf5daedff27eb2ada.tar.gz
Complete messages method for Matrix::Client::Room
Diffstat (limited to 'lib/Matrix/Client')
-rw-r--r--lib/Matrix/Client/Room.pm624
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/Matrix/Client/Room.pm6 b/lib/Matrix/Client/Room.pm6
index 72dfb62..3d6ecaa 100644
--- a/lib/Matrix/Client/Room.pm6
+++ b/lib/Matrix/Client/Room.pm6
@@ -82,15 +82,31 @@ method joined-members {
}
#| GET - /_matrix/client/r0/rooms/{roomId}/messages
-method messages() {
- my $res = $.get("/messages");
+method messages(
+ Str:D :$from!, Str :$to,
+ Str :$dir where * eq 'f'|'b' = 'f',
+ Int :$limit = 10, :%filter,
+ --> Matrix::Response::Messages
+) {
+ my $res = $.get(
+ "/messages", :$from, :$to, :$dir, :$limit, :%filter
+ );
my $data = from-json($res.content);
- return $data<chunk>.clone;
+
+ my @messages = $data<chunk>.map(-> $ev {
+ Matrix::Response::RoomEvent.new(|$ev)
+ });
+
+ Matrix::Response::Messages.new(
+ start => $data<start>,
+ end => $data<end>,
+ messages => @messages
+ )
}
#| GET - /_matrix/client/r0/rooms/{roomId}/members
-method members(:$at, Str :$membership, Str :$not-membership) {
+method members(:$at, Str :$membership, Str :$not-membership --> Seq) {
my %query;
%query<at> = $at with $at;