Changeset 948 for trunk/Defensio
- Timestamp:
- 08/11/08 16:47:50 (16 months ago)
- Files:
-
- 1 modified
-
trunk/Defensio/plugins/Defensio/Defensio.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Defensio/plugins/Defensio/Defensio.pl
r782 r948 42 42 handle_spam => \&handle_junk, 43 43 handle_ham => \&handle_not_junk, 44 'MT::Comment::pre_save' => \&pre_save_obj, 45 'MT::TBPing::pre_save' => \&pre_save_obj, 44 'MT::Entry::post_save' => \&post_save_obj, 45 'MT::Comment::pre_save' => \&pre_save_feedback_obj, 46 'MT::TBPing::pre_save' => \&pre_save_feedback_obj, 46 47 }, 47 48 junk_filters => { … … 109 110 } 110 111 111 sub pre_save_obj { 112 my ($cb, $obj) = @_; 113 if (!$obj->id && $obj->is_junk && ($obj->junk_log =~ m/Defensio says spam/)) { 114 # this was junked due in part to Defensio 115 # if (my $blog = $obj->blog) { 116 # $plugin->blocked( $blog, $plugin->blocked($blog) + 1 ); 117 # } 118 # $plugin->blocked( undef, $plugin->blocked() + 1 ); 119 } 112 sub pre_save_feedback_obj { 113 my ($cb, $obj, $orig) = @_; 114 1; 115 } 116 117 # This callback handler reports new entries to Defensio 118 sub post_save_obj { 119 my ($cb, $obj, $orig) = @_; 120 my $key = get_apikey() or return; 121 my $cli = Net::Defensio->new( api_key => $key ); 122 my $url = $app->base . $app->mt_uri; 123 my $res = $cli->announce_article( 124 owner_url => $url, 125 article_author => $obj->author->name, 126 article_author_email => $obj->author->email, 127 article_title => $obj->title, 128 article_content => $obj->text, 129 permalink => $obj->permalink, 130 ); 131 if ( !$res || !$res->success ) { 132 MT->log("Communications failure with Defensio"); 133 } elsif ( $res->status eq 'fail' ) { 134 MT->log("Defensio error: " . $res->message); 135 } 136 1; 120 137 } 121 138 … … 124 141 sub handle_junk { 125 142 my ($cb, $app, $thing) = @_; 126 print STDERR "Report false negative through Defensio\n";127 143 my $key = get_apikey() or return; 128 144 require Net::Defensio; 129 145 if (!$thing->defensio_sig) { # comment has NOT been rated by Defensio before 130 print STDERR "Never seen this comment before in Defensio - auditing...\n";131 146 my ($score,$grade) = defensio_score($thing); 132 147 } … … 140 155 ); 141 156 if ( !$res || !$res->success ) { 142 print STDERR "Communications failure with Defensio\n";143 157 MT->log("Communications failure with Defensio"); 144 158 } elsif ( $res->status eq 'fail' ) { 145 print STDERR "Defensio error: " . $res->message . "\n";146 159 MT->log("Defensio error: " . $res->message); 147 160 } 148 print STDERR "Done.\n";149 161 } 150 162 } … … 155 167 my ($cb, $app, $thing) = @_; 156 168 157 print STDERR "Report false positive through Defensio\n";158 169 my $key = get_apikey() or return; 159 170 require Net::Defensio; 160 171 if (!$thing->defensio_sig) { # comment has NOT been rated by Defensio before 161 print STDERR "Never seen this comment before in Defensio - auditing...\n";162 172 my ($score,$grade) = defensio_score($thing); 163 173 } … … 171 181 ); 172 182 if ( !$res || !$res->success ) { 173 print STDERR "Communications failure with Defensio\n";174 183 MT->log("Communications failure with Defensio"); 175 184 } elsif ( $res->status eq 'fail' ) { 176 print STDERR "Defensio error: " . $res->message . "\n";177 185 MT->log("Defensio error: " . $res->message); 178 186 } 179 print STDERR "Done.\n";180 187 } 181 188 } … … 186 193 my $key = get_apikey() or return MT::JunkFilter::ABSTAIN(); 187 194 188 print STDERR "Routing comment through Defensio...\n";189 195 my $cli = Net::Defensio->new( api_key => $key ); 190 196 my $params = _build_audit_params($thing);
