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

View File

@ -72,33 +72,22 @@ sub get_echo {
}
$db->commit();
# Get messages
my @msg_con;
# Get messages and populate hash
my $count = 0;
while ( $count < @new ) {
my $new_messages_url = "$host$msg_url" . $new[$count]->{hash};
my $req_msg = HTTP::Request->new( GET => $new_messages_url );
my $res_msg = $ua->request($req_msg);
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 {
print $res_msg->status_line, "\n";
}
$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