From 4823babb29e8d2c2f65b775e72210aac7a2175c5 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 17 May 2020 20:09:38 -0300 Subject: Add Matrix::Client::MediaStore class This is to wrap all the endpoints pointing to the media store. --- lib/Matrix/Client.pm6 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/Matrix/Client.pm6') diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 9022c65..2e26ee7 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -5,6 +5,7 @@ use Matrix::Response; use Matrix::Client::Common; use Matrix::Client::Room; use Matrix::Client::Requester; +use Matrix::Client::MediaStore; unit class Matrix::Client does Matrix::Client::Requester; @@ -331,16 +332,15 @@ method remove-room-alias($room-alias) { # Media -#| POST - /_matrix/media/r0/upload -method upload(IO::Path $path, Str $filename?) { - my $buf = slurp $path, :bin; - my $fn = $filename ?? $filename !! $path.basename; - my $res = $.post-bin("/upload", $buf, - content-type => "image/png", - filename => $fn, - ); - my $data = from-json($res.content); - $data // ""; +method media(--> Matrix::Client::MediaStore) { + return Matrix::Client::MediaStore.new( + home-server => $!home-server, + access-token => $!access-token + ) +} + +method upload(IO::Path $path, Str $filename?) is DEPRECATED('media.upload') { + self.media.upload($path, $filename) } # Misc -- cgit v1.2.3-54-g00ecf