From: harcoh@cs.kun.nl (Harco de Hilster)
Newsgroups: comp.soft-sys.andrew
Subject: Re: AMS Filtering
Date: 4 Sep 92 14:41:12 GMT
Organization: The Internet

Hi,

I use flames to handle our bulletin board. I got some sample andrew.cmu
flames files, and I followed the style closely. I've got it to work
reasonably, but the cmu style (or mine) of filtering messages has
troubles with multiple bboards in the to: field.

I want to be able to handle every bboard separately. Say I have two bboards:
loc+public
off+announce

I want to post a message to both of them but not every body is allowed
to post on off+announce. 
The to field looks like: 
"loc+public" <bbsman@cs.kun.nl>, "off+announce" <bbsman@cs.kun.nl>

The flames file looks like this:

; Filter function for bbsman

(defun bbsman-mail-hook (msg)
  (progn
   ; first get all relevant headers
   (let* ((hdrs (multi-GetHeaderContents msg '("to" "cc" "resent-to" "apparentl
y-to")))
          (offextrs (extract-liberally "offbb\\+"  hdrs))
          (locextrs (extract-liberally "locbb\\+"  hdrs))
          (extextrs (extract-liberally "extbb\\+"  hdrs))
          (prvextrs (extract-liberally "bbsman\\+" hdrs))
          (subj (getheadercontents msg "subject"))
          (sender (GetAuthSender msg))
          (to (getheadercontents msg "to")))
; handle the info-andrew mailing list
(cond ((a-str-in-any-str "info-andrew" hdrs T)
       (appendmsgtodir msg
"/vol/andrew/bboards/loc/.MESSAGES/andrew/mailing-list"))
      ; default handling of posting on official bulletin boards
      (offextrs (post-to-list msg
                              offextrs
                              "mail.lost"
                              (replyaddr msg "sender")
                              "bbsman@cs.kun.nl"
                              "There was a problem delivering your
message\n Does this bboard exists?\n Contact the bbsman if you have any
questions."
                              NIL
                              ; only the listed people are allowed to post on o
fficial
                              '(((".*") ("bbsman" "harcoh" "robd" "wim" "hansj"
 "yellak" "joycev") "You are not allowed to post on the official
bboard.\n Please contact the bbsman if you want to"))))
      ; handling of posting on local bulletin boards
      (locextrs
       (cond
        ; handle the public bulletin board
        ((a-str-in-any-str "public" locextrs T)
         (post-to-list msg
                       locextrs
                       "mail.lost"
                       (replyaddr msg "sender")
                       "bbsman@cs.kun.nl"
                       "There was a problem delivering your message\n
Please contact the bbsman."
                       T
                       NIL))
........ etc. ........

The Cond construct makes it impossible to have multiple bboards in the
to: field. Because the off condition succeeds the message is posted to
off+announce and the message to loc+public disappears. Not splitting the
messages in loc+, off+ and ext+ can make things worse. If the to field
contains off+ then all the messages are handled in the first
post-to-list.
This .AMS.flames file is very unsafe. If the to field contains
loc+public (the only bboard students can create sub-bboards on with no
access restriction) then all my further tests on loc+course.p1 (with
access restriction) are skiped.

What I really need is that for each item in the to field, the filter
function gets called. A message with two to fields is infact two
messages (HUH?). Since my flames file is similar to your own flames
files, you must have the same problem or am I missing something here.

Any suggestions?

Harco