diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-20 16:51:34 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-20 16:51:34 +0100 |
commit | d6fb798ba542bd1bda9f3d2359f1e447e91a489b (patch) | |
tree | 280075388c47cbe3ba89d97da997113f0e5fe1e0 | |
parent | 5ff2cb6203e950f08d33e457da8d3d3875283b40 (diff) |
check if comment is from known abuser
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 53337c6e7..22c0fb444 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -117,4 +117,29 @@ sub get_photo_params { return $photo; } + +=head2 is_from_abuser + + $bool = $update->is_from_abuser( ); + +Returns true if the user's email or its domain is listed in the 'abuse' table. + +=cut + +sub is_from_abuser { + my $self = shift; + + # get the domain + my $email = $self->user->email; + my ($domain) = $email =~ m{ @ (.*) \z }x; + + # search for an entry in the abuse table + my $abuse_rs = $self->result_source->schema->resultset('Abuse'); + + return + $abuse_rs->find( { email => $email } ) + || $abuse_rs->find( { email => $domain } ) + || undef; +} + 1; |