aboutsummaryrefslogtreecommitdiff
path: root/lib/Matrix/Client.pm6
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2018-06-04 23:17:02 -0300
committerMatias Linares <matiaslina@openmailbox.org>2018-06-04 23:17:02 -0300
commitbda35c5b13e2c7ff495d23bfc804a5adc5d08528 (patch)
treeeca49e1a96863c18237b301029bd7456c437c78e /lib/Matrix/Client.pm6
parentde4faaf9211308bd7f0fce524dbe1718b2dd88e9 (diff)
downloadperl6-matrix-client-bda35c5b13e2c7ff495d23bfc804a5adc5d08528.tar.gz
Clean room api a little
Diffstat (limited to 'lib/Matrix/Client.pm6')
-rw-r--r--lib/Matrix/Client.pm630
1 files changed, 7 insertions, 23 deletions
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6
index e380e95..89c464c 100644
--- a/lib/Matrix/Client.pm6
+++ b/lib/Matrix/Client.pm6
@@ -149,34 +149,15 @@ method create-room(
}
method join-room($room-id!) {
- $.post("/rooms/$room-id/join")
+ $.post("/join/$room-id")
}
method leave-room($room-id) {
$.post("/rooms/$room-id/leave");
}
-method rooms(Bool :$sync = False) {
- return @!rooms unless $sync;
- my $res = $.get("/sync", timeout => "30000");
-
- @!rooms = ();
- my $data = from-json($res.content);
- for $data<rooms><join>.kv -> $id, $json {
- @!rooms.push(Matrix::Client::Room.new(
- id => $id,
- json => $json,
- home-server => $!home-server,
- access-token => $!access-token
- ));
- }
-
- @!rooms
-}
-
method joined-rooms() {
my $res = $.get('/joined_rooms');
-
my $data = from-json($res.content);
return $data<joined_rooms>.Seq.map(-> $room-id {
Matrix::Client::Room.new(
@@ -193,9 +174,12 @@ method public-rooms() {
method send(Str $room-id, Str $body, :$type? = "m.text") {
$Matrix::Client::Common::TXN-ID++;
- $.put("/rooms/$room-id/send/m.room.message/{$Matrix::Client::Common::TXN-ID}",
- msgtype => $type, body => $body
- )
+ my $res = $.put(
+ "/rooms/$room-id/send/m.room.message/{$Matrix::Client::Common::TXN-ID}",
+ msgtype => $type, body => $body
+ );
+
+ from-json($res.content)<event_id>
}
# Media