chiark / gitweb /
Initial commit as found
[modbot-ulm.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         -I 'Bcc: webstump+urcm-internal-log+mailout' \
30         -I 'Bcc: webstump+urcm-internal-reject-copy'
31     (
32       echo "$EXPLANATION"
33       echo
34
35       if [ "x$REASON" != "xcustom" ] ; then
36         cat $MNG_ROOT/etc/messages/$REASON
37       fi
38
39       echo ""
40       echo ============================================ Full text of your message follows
41       sed 's/^/> /; s/webstump+[-+/0-9a-z]*@chiark/webstump+?@chiark/' \
42           < $MESSAGE
43     ) | gpg --clearsign --textmode --armor --batch --user "$PMUSER_APPROVAL" \
44          --passphrase "$PMPASSWORD" 2>/dev/null \
45   ) | sendmail -oi -t -f $MUNGED_ADDRESS
46 }
47
48 update_rejection_count() {
49   # don't count forgeries and signature mismatches against the victim
50   # also don't count thread rejections or duplicates
51   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
52     cat $MESSAGE | updateActionCount.pl -r
53   fi
54 }
55
56 #save
57 reply $1
58 #update_rejection_count
59 rm $MESSAGE
60
61 #    ) | stump-pgp -staf -z "$PMPASSWORD"       \
62 #            -u "$ROBOMOD_APPROVAL" +clearsig=on  2>/dev/null   \