ó
Hü½cc           @   sú   d  Z  d d l Z d d l m Z d d l m Z d d l m Z d d l m	 Z	 d d l m
 Z
 d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d e j f d „  ƒ  YZ d „  Z d „  Z d „  Z d S(   s   Posting moderation filter.
iÿÿÿÿN(   t   MIMEMessage(   t   MIMEText(   t	   parseaddr(   t   mm_cfg(   t   Utils(   t   Message(   t   Errors(   t   _(   t   Hold(   t   syslog(   t   MailListt   ModeratedMemberPostc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s8   /export/web/mailman/mailman/Mailman/Handlers/Moderate.pyR   %   s   	c         C   sÁ  | j  d ƒ r d  Sxs | j ƒ  D]_ } |  j | ƒ r9 Pn  x0 t j | |  j ƒ D] } |  j | ƒ rO PqO qO W|  j | ƒ r  Pq  q  Wd  } | rO|  j | t j	 ƒ rK|  j
 d k rÖ | | d <t j |  | | t ƒ qK|  j
 d k r|  j } | rt j | ƒ } n d  } t j | ‚ qK|  j
 d k r6t j ‚ qKd sKt d ƒ ‚ n  d  S| j ƒ  } |  j ƒ  } |  j | |  j d d ƒr†d  S|  j | |  j d d	 ƒr½t j |  | | t j ƒ n  |  j | |  j d d
 ƒråt |  ƒ n  |  j | |  j d d ƒrt |  | ƒ n  d |  j k o*d k n s5t ‚ |  j d k sS| j  d ƒ rWd  S|  j d k r‚t j |  | | t j ƒ n; |  j d k ržt |  ƒ n |  j d k r½t |  | ƒ n  d  S(   Nt   approvedi    t   senderi   i   s   bad member_moderation_actiont   at_listt   accept_these_nonmemberst   hold_these_nonmemberst   reject_these_nonmemberst   discard_these_nonmembersi   t
   fromuseneti   (   t   gett   get_senderst   isMemberR   t   check_eq_domainst   equivalent_domainst   Nonet   getMemberOptionR   t   Moderatet   member_moderation_actionR   t   hold_for_approvalR   t   member_moderation_noticet   wrapR   t   RejectMessaget   DiscardMessaget   AssertionErrort
   get_sendert   internal_namet
   GetPatternR   R   t   NonMemberPostR   t	   do_rejectR   t
   do_discardt   generic_nonmember_action(   t   mlistt   msgt   msgdataR   t   textt   listname(    (    s8   /export/web/mailman/mailman/Mailman/Handlers/Moderate.pyt   process2   sn    

													%c         C   sU   |  j  ƒ  } |  j r6 t j t j t |  j ƒ ƒ ‚ n t j t j t d ƒ ƒ ‚ d  S(   Ns  Your message has been rejected, probably because you are not subscribed to the
mailing list and the list's policy is to prohibit non-members from posting to
it.  If you think that your messages are being rejected in error, contact the
mailing list owner at %(listowner)s.(   t   GetOwnerEmailt   nonmember_rejection_noticeR   R"   R   R!   R   (   R,   t	   listowner(    (    s8   /export/web/mailman/mailman/Mailman/Handlers/Moderate.pyR)   ‹   s    	c         C   sØ   | j  ƒ  } |  j rË |  j } d |  j d d d ƒ} t j |  j ƒ  |  j ƒ  t d ƒ d | ƒ} | j	 d ƒ t
 t j t d ƒ ƒ d	 t j | ƒ ƒ} | j | ƒ | j t | ƒ ƒ | j |  ƒ n  t j ‚ d  S(
   Ns3   %s/?VARHELP=privacy/sender/discard_these_nonmemberst   admint   absolutei   s   Auto-discard notificationt   langs   multipart/mixeds6   The attached message has been automatically discarded.t   _charset(   R%   t   forward_auto_discardst   preferred_languaget   GetScriptURLR   t   UserNotificationR2   t   GetBouncesEmailR   t   set_typeR   R   R!   t
   GetCharSett   attachR    t   sendR   R#   (   R,   R-   R   R7   t   varhelpt   nmsgR/   (    (    s8   /export/web/mailman/mailman/Mailman/Handlers/Moderate.pyR*   ™   s"    				(   t   __doc__t   ret   email.MIMEMessageR    t   email.MIMETextR   t   email.UtilsR   t   MailmanR   R   R   R   t   Mailman.i18nR   t   Mailman.HandlersR   t   Mailman.Logging.SyslogR	   t   Mailman.MailListR
   t   ModeratedPostR   R1   R)   R*   (    (    (    s8   /export/web/mailman/mailman/Mailman/Handlers/Moderate.pyt   <module>   s    	Y	