From bda35c5b13e2c7ff495d23bfc804a5adc5d08528 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Mon, 4 Jun 2018 23:17:02 -0300 Subject: Clean room api a little --- lib/Matrix/Client.pm6 | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'lib/Matrix') 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.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.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) } # Media -- cgit v1.2.3-70-g09d2