ó
Eü½cc           @   s}   d  Z  d d l m Z m Z d d l m Z d d l m Z d Z y e	 e
 f Wn e k
 ro d Z	 d Z
 n Xd „  Z d	 S(
   sr  If the user wishes it, do not send duplicates of the same message.

This module keeps an in-memory dictionary of Message-ID: and recipient pairs.
If a message with an identical Message-ID: is about to be sent to someone who
has already received a copy, we either drop the message, add a duplicate
warning header, or pass it through, depending on the user's preferences.
iÿÿÿÿ(   t   getaddressest
   formataddr(   t   mm_cfg(   t   change_headers   , i   i    c         C   su  | d } | s d  Si  } |  j  ƒ  |  j ƒ  |  j ƒ  |  j ƒ  g } x | D] } t | | j ƒ  <qK Wi  } t } x• d D] }	 t | j |	 g  ƒ ƒ }
 |	 d k rÒ x- |
 D]" \ } } | | f | | j ƒ  <q© Wn  x0 |
 D]( \ } } | sñ qÙ n  t | | j ƒ  <qÙ Wqx Wx | D] } | | j ƒ  =qW| s1d  Sg  } x½ | D]µ } | j	 | j ƒ  ƒ ræt } |  j
 | ƒ rŒ|  j | t j ƒ rŒt } n  | r¸t | j d i  ƒ | <| j | ƒ qó| j	 | j ƒ  ƒ ró| | j ƒ  =t } qóq>| j | ƒ q>W| | d <| rW|  j rW| rWt d t j g  | j ƒ  D] } t | ƒ ^ q/ƒ |  | | ƒ n | rq|  j rq| d =n  d  S(	   Nt   recipst   tot   ccs	   resent-tos	   resent-ccs   add-dup-headert   Cc(   R   R   s	   resent-tos	   resent-cc(   t   GetListEmailt   GetBouncesEmailt   GetOwnerEmailt   GetRequestEmailt   Truet   lowert   FalseR    t   get_allt   has_keyt   isMembert   getMemberOptionR   t   DontReceiveDuplicatest
   setdefaultt   appendt   drop_ccR   t
   COMMASPACEt   joint   valuesR   (   t   mlistt   msgt   msgdataR   t   explicit_recipst	   listaddrst   addrt   ccaddrst   munge_cct   headert   addrst   namet	   newrecipst   rt   send_duplicatet   i(    (    s?   /export/web/mailman/mailman/Mailman/Handlers/AvoidDuplicates.pyt   process'   sX    
	
+N(   t   __doc__t   email.UtilsR    R   t   MailmanR   t   Mailman.Handlers.CookHeadersR   R   R   R   t	   NameErrorR)   (    (    (    s?   /export/web/mailman/mailman/Mailman/Handlers/AvoidDuplicates.pyt   <module>   s   
