Delete not send message
This commit is contained in:
parent
ac0086cab6
commit
f36235d64e
19
II/DB.pm
19
II/DB.pm
@ -34,8 +34,7 @@ sub check_hash {
|
||||
my ($base_hash) = @h;
|
||||
if ( $hash eq $base_hash ) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -84,6 +83,16 @@ sub write_out {
|
||||
print "Message writed to DB!\n";
|
||||
}
|
||||
|
||||
sub del_out {
|
||||
my ( $self, $hash ) = @_;
|
||||
my $dbh = $self->{_dbh};
|
||||
|
||||
my $q = "delete from output where hash='$hash' and send=0";
|
||||
my $sth = $dbh->prepare($q);
|
||||
$sth->execute();
|
||||
$sth->finish();
|
||||
}
|
||||
|
||||
sub update_out {
|
||||
my ( $self, $hash ) = @_;
|
||||
my $dbh = $self->{_dbh};
|
||||
@ -339,9 +348,9 @@ sub do_search {
|
||||
my ( $self, $query ) = @_;
|
||||
my $dbh = $self->{_dbh};
|
||||
|
||||
my $q = "select from_user, to_user, subg, time, echo, post, hash
|
||||
from messages where subg
|
||||
like '\%$query\%' COLLATE NOCASE
|
||||
my $q = "select from_user, to_user, subg, time, echo, post, hash
|
||||
from messages where subg
|
||||
like '\%$query\%' COLLATE NOCASE
|
||||
order by time";
|
||||
|
||||
print "SQL: " . $q . "\n";
|
||||
|
3
II/T.pm
3
II/T.pm
@ -194,7 +194,7 @@ sub pre {
|
||||
$post =~ s/ii:\/\/(\w{20})/<a href="\/send?hash=$1">$1<\/a>/g;
|
||||
|
||||
# Users
|
||||
$post =~ s/.+? \@(\w+)(.?.+)/<a href="\/u?user=$1">$1<\/a>$2/g;
|
||||
# $post =~ s/.+? \@(\w+)(.?.+)/<a href="\/u?user=$1">$1<\/a>$2/g;
|
||||
|
||||
# Not are regexp parsing
|
||||
my $pre = 0;
|
||||
@ -218,6 +218,7 @@ sub pre {
|
||||
$txt =~ s/<font.+>(>.+)<\/font>/$1/g if $pre == 1;
|
||||
}
|
||||
close $fh;
|
||||
$txt =~ s/\n/<br>/g;
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
18
iiplc.app
18
iiplc.app
@ -72,8 +72,7 @@ my $get = sub {
|
||||
my $GET = II::Get->new($config);
|
||||
$msgs .= $GET->get_echo();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
my $GET = II::Get->new($config);
|
||||
$msgs .= $GET->get_echo();
|
||||
}
|
||||
@ -206,6 +205,20 @@ my $search = sub {
|
||||
return [ 200, [ 'Content-type' => 'text/html' ], [$result], ];
|
||||
};
|
||||
|
||||
# Delete out message
|
||||
####################
|
||||
my $del = sub {
|
||||
my $env = shift;
|
||||
|
||||
my $req = Plack::Request->new($env);
|
||||
my $hash = $req->param('hash');
|
||||
|
||||
my $db = II::DB->new();
|
||||
$db->del_out($hash);
|
||||
|
||||
return [301, ['Location' => '/out'], [], ];
|
||||
};
|
||||
|
||||
# Mountpoints
|
||||
builder {
|
||||
mount "/static" => Plack::App::File->new( root => './s/' )->to_app;
|
||||
@ -222,4 +235,5 @@ builder {
|
||||
mount '/out' => $out;
|
||||
mount '/push' => $push;
|
||||
mount '/new' => $new;
|
||||
mount '/del' => $del;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user