# werc bridge with mail notification

# blah..........
# this is about line 85 or something
# (this is very old and unused for years - propably should have made a patch file...)

    if(~ $#_status 0) {
        umask 002
	if ($new_user)
		_status='Could not post comment, this user may not be approved yet.'

        dir=$dir'/'`{date -n} # FIXME Obvious race
        mkdir -m 775 -p $dir &&
		echo $u > $dir/user &&
		echo $current_date_time > $dir/posted &&
		echo $post_arg_comment_text > $dir/body
        _s=$status
        if(! ~ $"_s '') {
		dprint 'ERROR XXX: Could not create comment: ' $_s 
		_status='Could not post comment due internal error, sorry.'
        }
	# build and send notification mail
	if not {
		mail='/tmp/werc_bridge_mail'^$pid
		cat /usr/local/werc/apps/bridge/mail_header.tpl > $mail
		if ($new_user)
			echo 'New comment by NEW user: '^$post_arg_comment_user >> $mail
		if not
			echo 'New comment by user: '^$logged_user >> $mail
		echo 'Artikel: '^$base_url^$req_path >> $mail
		echo 'Time: '^$current_date_time >> $mail
		echo '' >> $mail
		#post_arg_comment_text=echo $post_arg_comment_text | sed 's/^\.$/|./'
		echo $"post_arg_comment_text >> $mail
		cat /usr/local/werc/apps/bridge/mail_footer.tpl >> $mail
		{sed 's/^\.$/. /' $mail; echo '.'} | /usr/sbin/sendmail -t
		rm $mail
	}
    }

    notify_errors=$_status
    status=$_status
}