diff options
| author | fukachan <fukachan> | 2004-10-28 03:32:52 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-10-28 03:32:52 +0000 |
| commit | ba51dec8662e71c443f0d3b456fb67e6a70540cd (patch) | |
| tree | 21aa06f14f1b069fbb8ecf12173ac2c2465c2261 /fml/lib/FML/Restriction | |
| parent | 8b3a5c2b4bccedb847dd44fe8eeeece03026010d (diff) | |
| download | fml8-ba51dec8662e71c443f0d3b456fb67e6a70540cd.tar.gz fml8-ba51dec8662e71c443f0d3b456fb67e6a70540cd.tar.bz2 fml8-ba51dec8662e71c443f0d3b456fb67e6a70540cd.zip | |
implement "check_article_thread" operation.
Itt allows post from someone who reffers articles within one weeks.
Diffstat (limited to 'fml/lib/FML/Restriction')
| -rw-r--r-- | fml/lib/FML/Restriction/Post.pm | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/fml/lib/FML/Restriction/Post.pm b/fml/lib/FML/Restriction/Post.pm index b5d9edc7..dac29f74 100644 --- a/fml/lib/FML/Restriction/Post.pm +++ b/fml/lib/FML/Restriction/Post.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Post.pm,v 1.12 2004/04/23 04:10:38 fukachan Exp $ +# $FML: Post.pm,v 1.13 2004/07/23 13:16:43 fukachan Exp $ # package FML::Restriction::Post; @@ -145,6 +145,51 @@ sub reject } +=head1 EXTENSION + +=cut + + +# Descriptions: check references and permit this message +# if it refers this thread. +# Arguments: OBJ($self) STR($rule) STR($sender) +# Side Effects: none +# Return Value: NUM +sub check_article_thread +{ + my ($self, $rule, $sender) = @_; + my $curproc = $self->{ _curproc }; + my $config = $curproc->config(); + my $header = $curproc->incoming_message_header(); + my $reflist = $header->extract_message_id_references() || []; + my $curtime = time; + my $limit = 3600*24*7; + my $match = 0; + + SEARCH_ID: + for my $id (@$reflist) { + my $a = { message_id => $id }; + my $r = $header->check_article_message_id($config, $a) || '0'; + + # ok if article within $limit (7 days) is referred. + if ($limit > $curtime - $r) { + $match = $curtime - $r; + last SEARCH_ID; + } + } + + # + if ($match) { + $curproc->log("check_article_thread matched. ($match sec old)"); + return("matched", "permit"); + } + else { + $curproc->log("check_article_thread failed."); + return(0, undef); + } +} + + =head1 CODING STYLE See C<http://www.fml.org/software/FNF/> on fml coding style guide. |
