~systers/systers/stable

« back to all changes in this revision

Viewing changes to Mailman/DlistUtils.py

  • Committer: Robin Jeffries
  • Date: 2009-02-22 03:44:04 UTC
  • Revision ID: robin@abiwt.org-20090222034404-w9k7me2w9nmm1lwt
fix bug where changing email address keeps subscriber from getting mail
and loses all aliases (bugs in the postgres database update

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
                pass
51
51
        else:
52
52
            cursor.execute(command)
53
 
        syslog('info', "DlistUtils: query succeeded")
 
53
        #syslog('info', "DlistUtils: query succeeded")
54
54
    # Return result of final operation
55
55
    try:
56
56
        result = cursor.fetchone()[0]
57
57
    except:
58
58
        result = None
59
 
        syslog('info', 'Result of query is /%s/', result)
 
59
        #syslog('info', 'Result of query is /%s/', result)
60
60
    conn.commit()
61
61
    return result
62
62
 
510
510
    executeSQL(mlist, "UPDATE subscriber SET mailman_key = '%s' WHERE mailman_key = '%s'" % (newaddr, oldaddr))
511
511
 
512
512
def mergeSubscribers(mlist, oldaddr, newaddr):
 
513
    # use the original subscriber id as the ID going forward
513
514
    new_id = executeSQL(mlist, ["SELECT subscriber_id FROM subscriber WHERE mailman_key = '%s'" % oldaddr])
514
515
    obsolete_id = executeSQL(mlist, ["SELECT subscriber_id FROM subscriber WHERE mailman_key = '%s'" % newaddr])
515
516
    executeSQL(mlist,
516
517
               [("UPDATE message SET sender_id = %d WHERE sender_id = %d" % (new_id, obsolete_id)),
517
518
                ("UPDATE override SET subscriber_id = %d WHERE subscriber_id = %d" % (new_id, obsolete_id)),
518
519
                ("UPDATE alias SET subscriber_id = %d WHERE subscriber_id = %d" % (new_id, obsolete_id)),
519
 
                ("DELETE from subscriber WHERE subscriber_id = %d" % obsolete_id)])
 
520
                ("DELETE from subscriber WHERE subscriber_id = %d" % obsolete_id),
 
521
                ("UPDATE subscriber SET deleted = FALSE WHERE subscriber_id = %d" %new_id)])
520
522
    
521
523
    
522
524
def enabled(mlist):
538
540
        subscribe_string = "subscribe"
539
541
        preposition = "to"
540
542
    email_addr = '%s+%s+%s@%s' % (mlist.internal_name(), thread_name, subscribe_string, mlist.host_name)
541
 
    syslog('info', "msg['Subject'] = /%s/", msg['Subject'])
 
543
    #syslog('info', "msg['Subject'] = /%s/", msg['Subject'])
542
544
    subject = urllib.quote(msg['Subject'].encode())
543
545
    post_addr = "%s+%s@%s" % (mlist.internal_name(), thread_name, mlist.host_name)
544
546
    post_addr_with_subject = "%s?Subject=%s" % (post_addr, subject)
545
 
    syslog('info', 'post_addr_with_subject = %s', post_addr)
 
547
    #syslog('info', 'post_addr_with_subject = %s', post_addr)
546
548
 
547
549
    # Used in Handlers/ToDigest.py
548
550
    msgdata['contribute'] = "To contribute to this conversation, send " \
553
555
    msgdata['contribute-html'] = 'To contribute to this conversation, send your message to <a href="mailto:%s">%s</a>\n' % (post_addr, post_addr)
554
556
 
555
557
    msgdata['footer-text'] = '\n\nTo %s %s this conversation, send email to <%s> or visit <%s>\nTo contribute to this conversation, use your mailer\'s reply-all or reply-group command or send your message to %s\nTo start a new conversation, send email to <%s+new@%s>\nTo unsubscribe entirely from %s, send email to <%s-request@%s> with subject unsubscribe.' % (subscribe_string, preposition, email_addr, web_addr, post_addr, mlist.internal_name(), mlist.host_name, mlist.internal_name(), mlist.internal_name(), mlist.host_name)
556
 
    syslog('info', 'footer-text = /%s/', msgdata['footer-text'])
 
558
    #syslog('info', 'footer-text = /%s/', msgdata['footer-text'])
557
559
    msgdata['footer-html'] = '<br>To %s %s this conversation, send email to <a href="mailto:%s">%s</a> or visit <a href="%s">%s</a>.<br>To contribute to this conversation, use your mailer\'s reply-all or reply-group command or send your message to <a href="mailto:%s?subject=%s">%s</a>.<br>To start a new conversation, send email to <a href="mailto:%s+new@%s">%s+new@%s</a><br>To unsubscribe entirely from %s, send mail to <a href="mailto:%s-request@%s?subject=unsubscribe">%s-request@%s</a> with subject unsubscribe.' % (subscribe_string, preposition, email_addr, email_addr, web_addr, web_addr, post_addr, subject, post_addr, mlist.internal_name(), mlist.host_name, mlist.internal_name(), mlist.host_name, mlist.internal_name(), mlist.internal_name(), mlist.host_name, mlist.internal_name(), mlist.host_name)
558
560
 
559
561
def canonicalize_sender(mlist, aliases):
563
565
                                      "SELECT s.mailman_key FROM subscriber s, alias a WHERE a.pseudonym='%s' AND s.subscriber_id = a.subscriber_id" % alias)
564
566
        if len(match) == 1:
565
567
            # I should really confirm that there is only one match
566
 
            syslog('info', 'Match: %s', match)
 
568
            #syslog('info', 'Match: %s', match)
567
569
            syslog('info', 'Match found: <%s>', match[0])
568
570
            return match[0]
569
571
        elif len(match) > 1: