aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Comment.pm
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-05-20 17:34:00 +0100
committerEdmund von der Burg <evdb@mysociety.org>2011-05-20 17:34:11 +0100
commit4305f38eeb503db4aac658839012b8e7644b455e (patch)
treeddfa8a29b5d2c30ddb7aacd40a58a2ae7de1df41 /perllib/FixMyStreet/DB/Result/Comment.pm
parent1e67ddbedf6481e3e8650a498679eafd710230ca (diff)
parentfb2eae201d01d285ac2b21fd32c2ff35a6f7aae5 (diff)
Merge branch 'migrate_to_catalyst' of ssh://evdb@git.mysociety.org/data/git/public/fixmystreet into migrate_to_catalyst
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Comment.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm25
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;