chiark / gitweb /
Remove more urcm-isms
[modbot-mtm.git] / stump / bin / processRejected
1 #!/bin/sh
2 #
3 # This script takes a raw article that is already rejected, creates a 
4 # reply message, signs it with PGP and sends back to the author.
5 #
6
7 # echo $0 invoked with arguments $@ 1>&2
8
9 MESSAGE=$TMP/rejected.$$
10
11 shift; REASON="$1"; export REASON; shift 
12 #EXPLANATION="$@"; export EXPLANATION
13
14 echo Action: processRejected, reason=$REASON 1>&2
15
16 cat  > $MESSAGE
17
18 #save() { 
19 #  procmail -p -f- $MNG_ROOT/etc/procmail/save-rejected < $MESSAGE
20 #}
21
22 reply() {
23
24   if [ "x$REASON" = xdiscard ]; then return; fi
25   (
26     cat $MESSAGE | formail -rt -I "Reply-To: $BOARD"    \
27                                -I "Errors-To: $MUNGED_ADDRESS"   \
28         -I "X-Webstump-Event: reject $REASON" \
29         $MAILOUT_REJECT_FORMAIL_ARGS
30     (
31       echo "$EXPLANATION"
32       echo
33
34       if [ "x$REASON" != "xcustom" ] ; then
35         cat $MNG_ROOT/etc/messages/$REASON
36       fi
37
38       echo ""
39       echo ============================================ Full text of your message follows
40       sanitise_and_quote_email \
41          < $MESSAGE
42     ) | gpg --clearsign --textmode --armor --batch --user "$PMUSER_APPROVAL" \
43          --passphrase "$PMPASSWORD" 2>/dev/null \
44   ) | sendmail -oi -t -f $MUNGED_ADDRESS
45 }
46
47 update_rejection_count() {
48   # don't count forgeries and signature mismatches against the victim
49   # also don't count thread rejections or duplicates
50   if [ "x$REASON" != "xforgery" -a "x$REASON" != "xsignature" -a "x$REASON" != "xthread" -a "x$REASON" != "xduplicate" -a "x$REASON" != "xcrosspost" -a "x$REASON" != "xempty" ]; then
51     cat $MESSAGE | updateActionCount.pl -r
52   fi
53 }
54
55 #save
56 reply $1
57 #update_rejection_count
58 rm $MESSAGE
59
60 #    ) | stump-pgp -staf -z "$PMPASSWORD"       \
61 #            -u "$ROBOMOD_APPROVAL" +clearsig=on  2>/dev/null   \