Changeset 52728

Show
Ignore:
Timestamp:
04/09/08 17:45:04 (2 years ago)
Author:
madarche
Message:

Fixed #1903: Notifications are received twice and/or received by the sender
email address.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • CPS3/products/CPSSubscriptions/trunk/CHANGES

    r52616 r52728  
    77Bug fixes 
    88~~~~~~~~~ 
    9 
     9- #1903: Notifications are received twice and/or received by the sender email 
     10  address. 
    1011New internal features 
    1112~~~~~~~~~~~~~~~~~~~~~ 
  • CPS3/products/CPSSubscriptions/trunk/Notifications.py

    r49552 r52728  
    11# -*- coding: ISO-8859-15 -*- 
    2 # Copyright (c) 2004-2005 Nuxeo SARL <http://nuxeo.com> 
     2# Copyright (c) 2004-2008 Nuxeo SAS <http://nuxeo.com> 
    33# Copyright (c) 2004 CGEY <http://cgey.com> 
    44# Copyright (c) 2004 Ministere de L'interieur (MISILL) 
     
    66# Authors : Julien Anguenot <ja@nuxeo.com> 
    77#           Florent Guillaume <fg@nuxeo.com> 
    8  
     8
    99# This program is free software; you can redistribute it and/or 
    1010# modify it under the terms of the GNU General Public License 
    1111# as published by the Free Software Foundation; either version 2 
    1212# of the License, or (at your option) any later version. 
    13  
     13
    1414# This program is distributed in the hope that it will be useful, 
    1515# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1616# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1717# GNU General Public License for more details. 
    18  
     18
    1919# You should have received a copy of the GNU General Public License 
    2020# along with this program; if not, write to the Free Software 
    2121# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     22# 
    2223# $Id$ 
    2324 
    2425__author__ = "Julien Anguenot <mailto:ja@nuxeo.com>" 
    2526 
    26 """ Notification rule classes 
     27"""Notification rule classes 
    2728 
    2829The something that is actually done.  Usually it involves Recipients (sending 
     
    132133        # Subject 
    133134        subject = infos['subject'] 
    134         subject = string.replace(subject, "\n", ""
     135        subject = string.replace(subject, '\n', ''
    135136 
    136137        # Header 
     
    138139 
    139140        # To 
    140         writer.addheader(string.capitalize('to'), 
    141                          mimify.mime_encode_header(infos['to'])) 
     141        if infos.get('to'): 
     142            writer.addheader(string.capitalize('to'), 
     143                             mimify.mime_encode_header(infos['to'])) 
    142144        # Bcc 
    143145        if infos.get('bcc'): 
     
    171173        """Validate the mail_infos structure 
    172174        """ 
    173  
    174175        return  (isinstance(mail_infos.get('sender_email'), str) and 
    175                  isinstance(mail_infos.get('to'), str) and 
     176                 # It is possible that no 'to' nor 'bcc' fields are specified 
     177                 isinstance(mail_infos.get('to', ''), str) and 
     178                 isinstance(mail_infos.get('bcc', ''), str) and 
    176179                 isinstance(mail_infos.get('subject'), str) and 
    177180                 isinstance(mail_infos.get('body'), tuple) and 
     
    183186        mail_infos contains all the needed information 
    184187        """ 
    185  
    186         # Check the mail strucuture 
    187         # It could be build by the user with whatever stuffs within. 
     188        # Check the mail structure 
    188189        if not self._validateStructure(mail_infos): 
    189             logger.error("sendMail() check the email of the recipients %r", 
     190            logger.error("sendMail() check the email of the recipients %r", 
    190191                         mail_infos) 
    191192            return -1 
     
    379380    def notifyRecipients(self, event_type, object_, infos=None, emails=[], 
    380381                         members=[], groups=[], **kw): 
    381         """ Notify recipients 
     382        """Notify recipients 
    382383 
    383384        This method will be called by the Subscription object when a 
     
    447448                'sender_email': semail, 
    448449                'subject': self._getSubject(infos), 
    449                 'to': semail, 
     450                # No 'to' field here, the many recipients 
     451                # are specified in the 'bcc' field. 
    450452                'bcc': bcc, 
    451453                'body': (body, mime_type),