- (nnheader-temp-write nil
- ;; Get the article.
- (gnus-message 7 "Checking article %d in %s for NoCeM..."
- (mail-header-number header) group)
- (let ((date (mail-header-date header))
- issuer b e)
- (when (or (not date)
- (nnmail-time-less
- (nnmail-time-since (nnmail-date-to-time date))
- (nnmail-days-to-time gnus-nocem-expiry-wait)))
- (gnus-request-article-this-buffer (mail-header-number header) group)
- ;; The article has to have proper NoCeM headers.
- (when (and (setq b (search-forward "\n@@BEGIN NCM HEADERS\n" nil t))
- (setq e (search-forward "\n@@BEGIN NCM BODY\n" nil t)))
- ;; We get the name of the issuer.
- (narrow-to-region b e)
- (setq issuer (mail-fetch-field "issuer"))
- (and (member issuer gnus-nocem-issuers) ; We like her...
- (gnus-nocem-verify-issuer issuer) ; She is who she says she is..
- (gnus-nocem-enter-article))))))) ; We gobble the message.
-
+ ;; Get the article.
+ (let ((date (mail-header-date header))
+ (gnus-newsgroup-name group)
+ issuer b e type)
+ (when (or (not date)
+ (time-less-p
+ (time-since (date-to-time date))
+ (days-to-time gnus-nocem-expiry-wait)))
+ (gnus-request-article-this-buffer (mail-header-number header) group)
+ (goto-char (point-min))
+ (when (re-search-forward "-----BEGIN PGP MESSAGE-----" nil t)
+ (delete-region (point-min) (match-beginning 0)))
+ (when (re-search-forward "-----END PGP MESSAGE-----\n?" nil t)
+ (delete-region (match-end 0) (point-max)))
+ (goto-char (point-min))
+ ;; The article has to have proper NoCeM headers.
+ (when (and (setq b (search-forward "\n@@BEGIN NCM HEADERS\n" nil t))
+ (setq e (search-forward "\n@@BEGIN NCM BODY\n" nil t)))
+ ;; We get the name of the issuer.
+ (narrow-to-region b e)
+ (setq issuer (mail-fetch-field "issuer")
+ type (mail-fetch-field "issuer"))
+ (widen)
+ (if (not (gnus-nocem-message-wanted-p issuer type))
+ (message "invalid NoCeM issuer: %s" issuer)
+ (and (gnus-nocem-verify-issuer issuer) ; She is who she says she is.
+ (gnus-nocem-enter-article) ; We gobble the message.
+ (push (mail-header-message-id header) ; But don't come back for
+ gnus-nocem-seen-message-ids))))))) ; second helpings.
+
+(defun gnus-nocem-message-wanted-p (issuer type)
+ (let ((issuers gnus-nocem-issuers)
+ wanted conditions condition)
+ (cond
+ ;; Do the quick check first.
+ ((member issuer issuers)
+ t)
+ ((setq conditions (cdr (assoc issuer issuers)))
+ ;; Check whether we want this type.
+ (while (setq condition (pop conditions))
+ (cond
+ ((stringp condition)
+ (setq wanted (string-match condition type)))
+ ((and (consp condition)
+ (eq (car condition) 'not)
+ (stringp (cadr condition)))
+ (setq wanted (not (string-match (cadr condition) type))))
+ (t
+ (error "Invalid NoCeM condition: %S" condition))))
+ wanted))))
+