Function: spam-report-gmane-internal

spam-report-gmane-internal is a byte-compiled function defined in spam-report.el.gz.

Signature

(spam-report-gmane-internal UNSPAM ARTICLE)

Documentation

Report ARTICLE as spam or not-spam through Gmane, depending on UNSPAM.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/spam-report.el.gz
(defun spam-report-gmane-internal (unspam article)
  "Report ARTICLE as spam or not-spam through Gmane, depending on UNSPAM."
  (when (and gnus-newsgroup-name
	     (or (null spam-report-gmane-regex)
		 (string-match spam-report-gmane-regex gnus-newsgroup-name)))
    (let ((rpt-host (if unspam "unspam.gmane.org" "spam.gmane.org")))
      (gnus-message 6 "Reporting article %d to %s..." article rpt-host)
      (cond
       ;; Special-case nnweb groups -- these have the URL to use in
       ;; the Xref headers.
       ((eq (car (gnus-find-method-for-group gnus-newsgroup-name)) 'nnweb)
	(spam-report-url-ping
	 rpt-host
	 (concat
	  "/"
	  (string-replace
	   "/" ":"
	   (replace-regexp-in-string
	    "^.*article.gmane.org/" ""
	    (replace-regexp-in-string
	     "/raw" ":silent"
	     (mail-header-xref (gnus-summary-article-header article))))))))
       (spam-report-gmane-use-article-number
	(spam-report-url-ping
	 rpt-host
	 (format "/%s:%d"
		 (gnus-group-real-name gnus-newsgroup-name)
		 article)))
       (t
	(with-current-buffer nntp-server-buffer
	  (erase-buffer)
	  (gnus-request-head article gnus-newsgroup-name)
	  (let ((case-fold-search t)
		field host report url)
	    ;; First check for X-Report-Spam because it's more specific to
	    ;; spam reporting than Archived-At.  OTOH, all new articles on
	    ;; Gmane don't have X-Report-Spam anymore (unless Lars changes his
	    ;; mind :-)).
	    ;;
	    ;; There might be more than one Archived-At header so we need to
	    ;; find (and transform) the one related to Gmane.
	    (setq field (or (gnus-fetch-field "X-Report-Spam")
			    (gnus-fetch-field "X-Report-Unspam")
			    (gnus-fetch-field "Archived-At")))
	    (if (not (stringp field))
		(if (and (setq field (gnus-fetch-field "Xref"))
			 (string-match "[^ ]+ +\\([^ ]+\\)" field))
		    (setq report (concat "/" (match-string 1 field))
			  host rpt-host))
	      (setq host
		    (progn
		      (string-match
		       (concat "http://\\([a-z]+\\.gmane\\.org\\)"
			       "\\(/[^:/]+[:/][0-9]+\\)")
		       field)
		      (match-string 1 field)))
	      (setq report (match-string 2 field)))
	    (when host
	      (when (string-equal "permalink.gmane.org" host)
		(setq host rpt-host)
		(setq report (replace-regexp-in-string "/\\([0-9]+\\)$" ":\\1"
						     report)))
	      (setq url (format "http://%s%s" host report)))
	    (if (not (and host report url))
		(gnus-message
		 3 "Could not find a spam report header in article %d..."
		 article)
	      (gnus-message 7 "Reporting article through URL %s..." url)
	      (spam-report-url-ping host report)))))))))