comparison roundup/mailgw.py @ 1103:db787cef1385

handled some XXXs
author Richard Jones <richard@users.sourceforge.net>
date Tue, 10 Sep 2002 12:44:42 +0000
parents fa7df238e2d4
children 1c1ccfc9673d
comparison
equal deleted inserted replaced
1102:d94bd5369456 1103:db787cef1385
71 set() method to add the message to the item's spool; in the second case we 71 set() method to add the message to the item's spool; in the second case we
72 are calling the create() method to create a new node). If an auditor raises 72 are calling the create() method to create a new node). If an auditor raises
73 an exception, the original message is bounced back to the sender with the 73 an exception, the original message is bounced back to the sender with the
74 explanatory message given in the exception. 74 explanatory message given in the exception.
75 75
76 $Id: mailgw.py,v 1.85 2002-09-10 03:01:18 richard Exp $ 76 $Id: mailgw.py,v 1.86 2002-09-10 12:44:42 richard Exp $
77 ''' 77 '''
78 78
79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
80 import time, random 80 import time, random
81 import traceback, MimeWriter 81 import traceback, MimeWriter
390 390
391 Subject was: "%s" 391 Subject was: "%s"
392 '''%(nodeid, subject) 392 '''%(nodeid, subject)
393 393
394 # 394 #
395 # handle the users
396 #
397 # Don't create users if anonymous isn't allowed to register
398 create = 1
399 anonid = self.db.user.lookup('anonymous')
400 if not self.db.security.hasPermission('Email Registration', anonid):
401 create = 0
402
403 # ok, now figure out who the author is - create a new user if the
404 # "create" flag is true
405 author = uidFromAddress(self.db, message.getaddrlist('from')[0],
406 create=create)
407
408 # no author? means we're not author
409 if not author:
410 raise Unauthorized, '''
411 You are not a registered user.
412
413 Unknown address: %s
414 '''%message.getaddrlist('from')[0][1]
415
416 # make sure the author has permission to use the email interface
417 if not self.db.security.hasPermission('Email Access', author):
418 raise Unauthorized, 'You are not permitted to access this tracker.'
419
420 # make sure they're allowed to edit this class of information
421 if not self.db.security.hasPermission('Edit', author, classname):
422 raise Unauthorized, 'You are not permitted to edit %s.'%classname
423
424 # the author may have been created - make sure the change is
425 # committed before we reopen the database
426 self.db.commit()
427
428 # reopen the database as the author
429 username = self.db.user.get(author, 'username')
430 self.db = self.instance.open(username)
431
432 # re-get the class with the new database connection
433 cl = self.db.getclass(classname)
434
435 # now update the recipients list
436 recipients = []
437 tracker_email = self.instance.config.TRACKER_EMAIL.lower()
438 for recipient in message.getaddrlist('to') + message.getaddrlist('cc'):
439 r = recipient[1].strip().lower()
440 if r == tracker_email or not r:
441 continue
442
443 # look up the recipient - create if necessary (and we're
444 # allowed to)
445 recipient = uidFromAddress(self.db, recipient, create)
446
447 # if all's well, add the recipient to the list
448 if recipient:
449 recipients.append(recipient)
450
451 #
395 # extract the args 452 # extract the args
396 # 453 #
397 subject_args = m.group('args') 454 subject_args = m.group('args')
398 455
399 # 456 #
518 There were problems handling your subject line argument list: 575 There were problems handling your subject line argument list:
519 - %s 576 - %s
520 577
521 Subject was: "%s" 578 Subject was: "%s"
522 '''%(errors, subject) 579 '''%(errors, subject)
523
524 #
525 # handle the users
526 #
527
528 # Don't create users if anonymous isn't allowed to register
529 create = 1
530 anonid = self.db.user.lookup('anonymous')
531 if not self.db.security.hasPermission('Email Registration', anonid):
532 create = 0
533
534 # ok, now figure out who the author is - create a new user if the
535 # "create" flag is true
536 author = uidFromAddress(self.db, message.getaddrlist('from')[0],
537 create=create)
538
539 # no author? means we're not author
540 if not author:
541 raise Unauthorized, '''
542 You are not a registered user.
543
544 Unknown address: %s
545 '''%message.getaddrlist('from')[0][1]
546
547 # make sure the author has permission to use the email interface
548 if not self.db.security.hasPermission('Email Access', author):
549 raise Unauthorized, 'You are not permitted to access this tracker.'
550
551 # the author may have been created - make sure the change is
552 # committed before we reopen the database
553 self.db.commit()
554
555 # reopen the database as the author
556 username = self.db.user.get(author, 'username')
557 self.db = self.instance.open(username)
558
559 # re-get the class with the new database connection
560 cl = self.db.getclass(classname)
561
562 # now update the recipients list
563 recipients = []
564 tracker_email = self.instance.config.TRACKER_EMAIL.lower()
565 for recipient in message.getaddrlist('to') + message.getaddrlist('cc'):
566 r = recipient[1].strip().lower()
567 if r == tracker_email or not r:
568 continue
569
570 # look up the recipient - create if necessary (and we're
571 # allowed to)
572 recipient = uidFromAddress(self.db, recipient, create)
573
574 # if all's well, add the recipient to the list
575 if recipient:
576 recipients.append(recipient)
577 580
578 # 581 #
579 # handle message-id and in-reply-to 582 # handle message-id and in-reply-to
580 # 583 #
581 messageid = message.getheader('message-id') 584 messageid = message.getheader('message-id')

Roundup Issue Tracker: http://roundup-tracker.org/