diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2018-06-04 23:17:02 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2018-06-04 23:17:02 -0300 |
commit | bda35c5b13e2c7ff495d23bfc804a5adc5d08528 (patch) | |
tree | eca49e1a96863c18237b301029bd7456c437c78e /lib | |
parent | de4faaf9211308bd7f0fce524dbe1718b2dd88e9 (diff) | |
download | perl6-matrix-client-bda35c5b13e2c7ff495d23bfc804a5adc5d08528.tar.gz |
Clean room api a little
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Matrix/Client.pm6 | 30 |
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 |