# vim: set syntax=perl ts=4 ai si:

##### IMPORTANT! - READ CAREFULLY #
# This is a minimalistic cleanfeed.local which Italian sites can install
# without much work.
# Things which need to be configured are marked with XXX.
# Don't forget to update $config_dir at the beginning of the cleanfeed file.
##### IMPORTANT! - READ CAREFULLY #

sub local_filter_first {
	my $localpost = 0;

#####
##### XXX: change the following line to match your servers
#####
$localpost = 1 if $hdr{'X-Trace'} and $hdr{'X-Trace'} =~ /autistici\.org /;

	study $hdr{__BODY__} if $hdr{__LINES__} <= 250;

	# local posts ####
	if ($localpost) {
		if ($hdr{Approved}) {
		    foreach (@groups) {
				if (not /^autistici\.ml\./) {
					saveart('CF.approved');
                return reject("Forged approval in $_ ($hdr{Approved})");
				}
		    }
		}

		return reject('Non usare HTML in Usenet!')
		if $hdr{'Content-Type'} and ($hdr{'Content-Type'} =~ m#text/html#
				or $hdr{'Content-Type'} =~ m#multipart/alternative#);
	}
	##############

    foreach (@groups) {
		$gr{it}++ if $hdr{Newsgroups} =~ /^it/;
	}

	# enforce it.* hierarchy restrictions
	if ($gr{it} and (@groups > 10 or @followups > 3)) {
		saveart('CF.ECP');
		return reject('Excessive crosspost');
	}

	# specific sites or companies #
	return reject("Job spam ($1)")
		if $hdr{From} =~ /@(ajilon\.ca|ntes\.com|offsitetechies\.com)\b/ 
			or $hdr{'Message-ID'} =~ /\@((?:webhire|hrsites)\.com)>$/;
			
	return reject('NNTP Monitor', 'Bot Signature')
		if $hdr{From} =~ /^NNTP-Monitor\@/;

}


sub local_filter_reject {
		my ($vr, $sr) = @_;
		saveart('R.nanacancel') if $vr eq 'Cancel in forbidden group';
		saveart('CF.scoring', $vr) if $vr =~ /^Scoring filter/;
		saveart('Z.EMP', $vr) if $vr =~ /^EMP/;
		saveart('W.supersedes') if $vr =~ /^Excessive Supersedes/;
		return @_;
}		


#####
##### XXX: change the paths to suit your system
#####
sub local_config {
	%config_local = (
		block_late_cancels => 1,

#####
##### XXX only highwind users need one
#####
#		active_file => '/news/common/active',

		statfile => '/var/log/news/cleanfeed.stats',
		html_statfile => '/var/log/news/cleanfeed.stats.html',

		do_emp_dump => 1,
		emp_dump_file => '/var/log/news/empdump',

#		debug_batch_directory => '/news/spam',
	);

}

print %config_local.@followups if 0; # lint food

1;