Handle all media types (image/audio/video)

Also don't use Image::Size, not strictly required
tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent 10ca028c53
commit ee456446b8
  1. 1
      README.md
  2. 1
      patrix.spec
  3. 13
      scripts/patrix

@ -15,7 +15,6 @@ It requires the following perl modules
* Term::ReadKey
* Hash::Merge::Simple
* Scalar::Util
* Image::Size
Here're the vailable options:

@ -23,7 +23,6 @@ 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

@ -15,7 +15,6 @@ use URI::Escape;
use Term::ReadKey;
use Hash::Merge::Simple qw(merge);
use Scalar::Util qw(looks_like_number);
use Image::Size;
our $opt;
@ -269,7 +268,6 @@ sub send_file {
content_type => $mime,
content => slurp($file)
});
debug("File upload response is\n" . to_json(from_json($resp->decoded_content), { pretty => 1 }));
die "Error uploading file\n" unless ($resp->is_success);
# If everything went well, the server replied with the URI of our file, which we can
# now post on the room
@ -288,12 +286,15 @@ sub send_file {
},
url => $file_uri
};
# If the file is an image, audio or video, send it as such
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);
}
elsif ($mime =~ /^audio/){
$json->{msgtype} = 'm.audio';
}
elsif ($mime =~ /^video/){
$json->{msgtype} = 'm.video';
}
$resp = send_request({
uri => $uri,

Loading…
Cancel
Save