chiark / gitweb /
Make noack honoured for approvals too
[modbot-mtm.git] / stump / bin / processRejected
1 #!/bin/bash
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 set -e
8
9 # echo $0 invoked with arguments $@ 1>&2
10
11 MESSAGE=$TMP/rejected.$$
12
13 shift; REASON="$1"; export REASON; shift 
14 #EXPLANATION="$@"; export EXPLANATION
15
16 echo Action: processRejected, reason=$REASON 1>&2
17
18 cat  > $MESSAGE
19
20 #save() { 
21 #  procmail -p -f- $MNG_ROOT/etc/procmail/save-rejected < $MESSAGE
22 #}
23
24 reply() {
25
26   if [ "x$REASON" = xdiscard ]; then return; fi
27   (
28     eventheader="reject $REASON"
29     if [ "x$WEBSTUMP_MESSAGENUM" != x ]; then
30         eventheader="[$WEBSTUMP_MESSAGENUM] $eventheader"
31     fi
32     cat $MESSAGE | formail -rt -I "Reply-To: $BOARD"    \
33                                -I "Errors-To: $MUNGED_ADDRESS"   \
34         -I "X-Webstump-Event: $eventheader" \
35         $MAILOUT_REJECT_FORMAIL_ARGS
36     (
37       echo "$EXPLANATION"
38       echo
39
40       if [ "x$REASON" != "xcustom" ] ; then
41         cat $MNG_ROOT/etc/messages/$REASON
42       fi
43
44       echo ""
45       echo ============================================ Full text of your message follows
46       sanitise_and_quote_email \
47          < $MESSAGE
48     ) | gpg --clearsign --textmode --armor --batch --user "$PMUSER_APPROVAL" \
49          --passphrase "$PMPASSWORD" 2>/dev/null \
50   ) | sendmail -oi -t -f $MUNGED_ADDRESS
51 }
52
53 update_rejection_count() {
54   # don't count forgeries and signature mismatches against the victim
55   # also don't count thread rejections or duplicates
56   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
57     cat $MESSAGE | updateActionCount.pl -r
58   fi
59 }
60
61 #save
62 reply $1
63 #update_rejection_count
64 rm $MESSAGE
65
66 #    ) | stump-pgp -staf -z "$PMPASSWORD"       \
67 #            -u "$ROBOMOD_APPROVAL" +clearsig=on  2>/dev/null   \