Long messages fix.

This commit is contained in:
Difrex(Denis Zheleztsov) 2014-08-06 12:16:16 +04:00
parent da55487653
commit e3cb17e173
2 changed files with 7 additions and 21 deletions

View File

@ -21,11 +21,7 @@ sub new {
sub decrypt { sub decrypt {
my ( $self, $base64 ) = @_; my ( $self, $base64 ) = @_;
# Decrypt message return decode_base64($base64);
my $dec = decode_base64($base64);
# my $dec = `echo "$base64" | base64 -d`;
return $dec;
} }
sub encode { sub encode {
@ -42,7 +38,8 @@ sub encode {
$message .= '@repto:' . $data->{hash} . "\n" if defined( $data->{hash} ); $message .= '@repto:' . $data->{hash} . "\n" if defined( $data->{hash} );
$message .= $data->{post}; $message .= $data->{post};
my $encoded = `echo "$message" | base64`; # my $encoded = `echo "$message" | base64`;
my $encoded = encode_base64($message);
$encoded =~ s/\//_/g; $encoded =~ s/\//_/g;
$encoded =~ s/\+/-/g; $encoded =~ s/\+/-/g;

View File

@ -72,33 +72,22 @@ sub get_echo {
} }
$db->commit(); $db->commit();
# Get messages # Get messages and populate hash
my @msg_con;
my $count = 0; my $count = 0;
while ( $count < @new ) { while ( $count < @new ) {
my $new_messages_url = "$host$msg_url" . $new[$count]->{hash}; my $new_messages_url = "$host$msg_url" . $new[$count]->{hash};
my $req_msg = HTTP::Request->new( GET => $new_messages_url ); my $req_msg = HTTP::Request->new( GET => $new_messages_url );
my $res_msg = $ua->request($req_msg); my $res_msg = $ua->request($req_msg);
if ( $res_msg->is_success() ) { if ( $res_msg->is_success() ) {
push( @msg_con, $res_msg->content() ); my ( $hash, $m ) = split(':', $res_msg->content());
push( @messages_hash, { hash => $hash, base64 => $m } );
} }
else { else {
print $res_msg->status_line, "\n"; print $res_msg->status_line, "\n";
} }
$count++; $count++;
} }
# Populate hash
while (<@msg_con>) {
my @message = split /:/, $_;
if ( defined( $message[1] ) ) {
my $h = {
hash => $message[0],
base64 => $message[1],
};
push( @messages_hash, $h );
}
}
} }
my $new_messages my $new_messages