mirror of https://github.com/dani/patrix.git
Support sending images
This commit is contained in:
parent
e19d403832
commit
10ca028c53
|
@ -15,6 +15,7 @@ It requires the following perl modules
|
|||
* Term::ReadKey
|
||||
* Hash::Merge::Simple
|
||||
* Scalar::Util
|
||||
* Image::Size
|
||||
|
||||
Here're the vailable options:
|
||||
|
||||
|
|
1
TODO
1
TODO
|
@ -1,7 +1,6 @@
|
|||
* Purge history of a room
|
||||
* Purge history of all empty rooms (with no members)
|
||||
* Modify federation setting of a room
|
||||
* Send image
|
||||
* Set room avatar
|
||||
* Configure user profile (name, avatar)
|
||||
* Follow discussion of a room (like a tail -f of the room discussion)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Name: patrix
|
||||
Version: 0.1.2
|
||||
Release: 2%{?dist}
|
||||
Version: 0.1.3
|
||||
Release: 1%{?dist}
|
||||
Summary: Command line client for Matrix
|
||||
|
||||
Group: Applications/Internet
|
||||
|
@ -23,6 +23,7 @@ Requires: perl(URI::Escape)
|
|||
Requires: perl(Term::ReadKey)
|
||||
Requires: perl(Hash::Merge::Simple)
|
||||
Requires: perl(Scalar::Util)
|
||||
Requires: perl(Image::Size)
|
||||
|
||||
%description
|
||||
Patrix is a simple (and quite limited) client for the Matrix communication network
|
||||
|
@ -52,6 +53,9 @@ room via the command line.
|
|||
%{_bindir}/patrix
|
||||
|
||||
%changelog
|
||||
* Wed Sep 13 2017 Daniel Berteaud <daniel@firewall-services.com> - 0.1.3-1
|
||||
- New release
|
||||
|
||||
* Wed Sep 13 2017 Daniel Berteaud <daniel@firewall-services.com> - 0.1.2-2
|
||||
- Fix perl dependency in spec file
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use URI::Escape;
|
|||
use Term::ReadKey;
|
||||
use Hash::Merge::Simple qw(merge);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use Image::Size;
|
||||
|
||||
our $opt;
|
||||
|
||||
|
@ -262,9 +263,10 @@ sub send_file {
|
|||
# And then we post the uri on the room
|
||||
debug("Uploading file $file to the media store");
|
||||
my $uri = $opt->{server} . '/_matrix/media/v1/upload?access_token=' . $opt->{access_token} . '&filename=' . basename($file);
|
||||
my $mime = mimetype($file);
|
||||
my $resp = send_request({
|
||||
uri => $uri,
|
||||
content_type => mimetype($file),
|
||||
content_type => $mime,
|
||||
content => slurp($file)
|
||||
});
|
||||
debug("File upload response is\n" . to_json(from_json($resp->decoded_content), { pretty => 1 }));
|
||||
|
@ -286,6 +288,13 @@ sub send_file {
|
|||
},
|
||||
url => $file_uri
|
||||
};
|
||||
if ($mime =~ m/^image/){
|
||||
# The file is an image, change the message type and add the required info so it is
|
||||
# displayed as an image
|
||||
my ($w,$h) = imgsize($file);
|
||||
$json->{msgtype} = 'm.image';
|
||||
($json->{info}->{h}, $json->{info}->{w}) = imgsize($file);
|
||||
}
|
||||
$resp = send_request({
|
||||
uri => $uri,
|
||||
content => to_json($json)
|
||||
|
|
Loading…
Reference in New Issue