diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-26 17:17:24 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-26 17:17:24 +0100 |
commit | 860f2965f9af0699a40e022ba7c7370a304a4313 (patch) | |
tree | 3cf65ef4fedf85a343d3d290288b73d26b4585fa /perllib/FixMyStreet/DB/Result/Comment.pm | |
parent | f7a711c5b544d876928ba572f46912e09eff9b83 (diff) |
use moose role for is_from_abuser method
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Comment.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 9b5feb37d..4c70dd902 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -72,6 +72,11 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:71bSUgPf3uW607g2EGl/Vw use DateTime::TimeZone; +use Moose; +use namespace::clean -except => [ 'meta' ]; + +with 'FixMyStreet::Roles::Abuser'; + my $tz = DateTime::TimeZone->new( name => "local" ); sub created_local { @@ -134,28 +139,7 @@ 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; -} +# we need the inline_constructor bit as we don't inherit from Moose +__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); 1; |