Function: nnmail-check-duplication

nnmail-check-duplication is a byte-compiled function defined in nnmail.el.gz.

Signature

(nnmail-check-duplication MESSAGE-ID FUNC ARTNUM-FUNC &optional JUNK-FUNC)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnmail.el.gz
(defun nnmail-check-duplication (message-id func artnum-func
					    &optional junk-func)
  (run-hooks 'nnmail-prepare-incoming-message-hook)
  ;; If this is a duplicate message, then we do not save it.
  (let* ((duplication (nnmail-cache-id-exists-p message-id))
	 (case-fold-search t)
	 (action (when duplication
		   (cond
		    ((memq nnmail-treat-duplicates '(warn delete))
		     nnmail-treat-duplicates)
		    ((functionp nnmail-treat-duplicates)
		     (funcall nnmail-treat-duplicates message-id))
		    (t
		     nnmail-treat-duplicates))))
	 group-art)
    ;; We insert a line that says what the mail source is.
    (let ((case-fold-search t))
      (goto-char (point-min))
      (re-search-forward "^message-id[ \t]*:" nil t)
      (beginning-of-line)
      (insert (format "X-Gnus-Mail-Source: %s\n" mail-source-string)))

    ;; Let the backend save the article (or not).
    (cond
     ((not duplication)
      (funcall func (setq group-art
			  (nreverse (nnmail-article-group
				     artnum-func nil junk-func))))
      (nnmail-cache-insert message-id (caar group-art)))
     ((eq action 'delete)
      (setq group-art nil))
     ((eq action 'warn)
      ;; We insert a warning.
      (let ((case-fold-search t))
	(goto-char (point-min))
	(re-search-forward "^message-id[ \t]*:" nil t)
	(beginning-of-line)
	(insert
	 "Gnus-Warning: This is a duplicate of message " message-id "\n")
	(funcall func (setq group-art
			    (nreverse (nnmail-article-group artnum-func))))))
     (t
      (funcall func (setq group-art
			  (nreverse (nnmail-article-group artnum-func))))))
    ;; Add the group-art list to the history list.
    (if group-art
	;; We need to get the unique Gnus group name for this article
	;; -- there may be identically named groups from several
	;; backends.
	(push (mapcar
	       (lambda (ga)
		 (cons (gnus-group-prefixed-name (car ga) gnus-command-method)
		       (cdr ga)))
	       group-art)
	      nnmail-split-history)
      (delete-region (point-min) (point-max)))))