(spam-mark-junk-as-spam-routine)
[gnus] / lisp / spam-report.el
index 0d4c3e2..78f29b6 100644 (file)
@@ -1,5 +1,5 @@
 ;;; spam-report.el --- Reporting spam
-;; Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <tzz@lifelogs.com>
 ;; Keywords: network
 (require 'gnus)
 (require 'gnus-sum)
 
+(eval-and-compile
+  (autoload 'mm-url-insert "mm-url"))
+
 (defgroup spam-report nil
   "Spam reporting configuration.")
 
 (defcustom spam-report-gmane-regex nil
   "Regexp matching Gmane newsgroups, e.g. \"^nntp\\+.*:gmane\\.\"
-If you are using spam.el, consider setting gnus-spam-process-newsgroups 
-or the gnus-group-spam-exit-processor-report-gmane group/topic parameter 
+If you are using spam.el, consider setting gnus-spam-process-newsgroups
+or the gnus-group-spam-exit-processor-report-gmane group/topic parameter
 instead."
-  :type 'regexp
+  :type '(radio (const nil)
+               (regexp :format "%t: %v\n" :size 0 :value "^nntp\+.*:gmane\."))
   :group 'spam-report)
 
-(defcustom spam-report-gmane-spam-header 
+(defcustom spam-report-gmane-spam-header
   "^X-Report-Spam: http://\\([^/]+\\)\\(.*\\)$"
   "String matching Gmane spam-reporting header.  Two match groups are needed."
   :type 'regexp
@@ -53,18 +57,74 @@ instead."
   :type 'boolean
   :group 'spam-report)
 
-(defun spam-report-gmane (article)
+(defcustom spam-report-url-ping-function
+  'spam-report-url-ping-plain
+  "Function to use for url ping spam reporting.
+The function must accept the arguments `host' and `report'."
+  :type '(choice
+         (const :tag "Connect directly"
+                spam-report-url-ping-plain)
+         (const :tag "Use the external program specified in `mm-url-program'"
+                spam-report-url-ping-mm-url)
+         (const :tag "Store request URLs in `spam-report-requests-file'"
+                spam-report-url-to-file)
+         (function :tag "User defined function" nil))
+  :group 'spam-report)
+
+(defcustom spam-report-requests-file
+  (nnheader-concat gnus-directory "spam/" "spam-report-requests.url")
+  ;; Is there a convention for the extension of such a file?
+  ;; Should we use `spam-directory'?
+  "File where spam report request are stored."
+  :type 'file
+  :group 'spam-report)
+
+(defcustom spam-report-resend-to nil
+  "Email address that spam articles are resent to when reporting.
+If not set, the user will be prompted to enter a value which will be
+saved for future use."
+  :type 'string
+  :group 'spam-report)
+
+(defvar spam-report-url-ping-temp-agent-function nil
+  "Internal variable for `spam-report-agentize' and `spam-report-deagentize'.
+This variable will store the value of `spam-report-url-ping-function' from
+before `spam-report-agentize' was run, so that `spam-report-deagentize' can
+undo that change.")
+
+(defun spam-report-resend (articles)
+  "Report an article as spam by resending via email."
+  (dolist (article articles)
+    (gnus-message 6 
+                 "Reporting spam article %d to <%s>..." 
+                 article spam-report-resend-to)
+    (unless spam-report-resend-to
+      (customize-set-variable 
+       spam-report-resend-to
+       (read-from-minibuffer "email address to resend SPAM to? ")))
+    ;; This is ganked from the `gnus-summary-resend-message' function.
+    ;; It involves rendering the SPAM, which is undesirable, but there does
+    ;; not seem to be a nicer way to achieve this.
+    ;; select this particular article
+    (gnus-summary-select-article nil nil nil article)
+    ;; resend it to the destination address
+    (save-excursion
+      (set-buffer gnus-original-article-buffer)
+      (message-resend spam-report-resend-to))))
+
+(defun spam-report-gmane (&rest articles)
   "Report an article as spam through Gmane"
-  (interactive "nEnter the article number: ")
-  (when (and gnus-newsgroup-name
-            (or (null spam-report-gmane-regex)
-                (string-match spam-report-gmane-regex gnus-newsgroup-name)))
-    (gnus-message 6 "Reporting spam article %d to spam.gmane.org..." article)
+  (dolist (article articles)
+    (when (and gnus-newsgroup-name
+              (or (null spam-report-gmane-regex)
+                  (string-match spam-report-gmane-regex gnus-newsgroup-name)))
+      (gnus-message 6 "Reporting spam article %d to spam.gmane.org..." article)
       (if spam-report-gmane-use-article-number
-         (spam-report-url-ping "spam.gmane.org" 
-                   (format "/%s:%d"
-                           (gnus-group-real-name gnus-newsgroup-name)
-                           article))
+         (spam-report-url-ping