comparison roundup/mailgw.py @ 6941:bd2c3b2010c3

issue2551232 - modify in-reply-to threading when multiple matches if an email is missing an issue designator, in-reply-to threading is attempted. In this change if in-reply-to threading matches multiple issues, fall back to matching on subject. It used to just arbitrairly choose the first matching issue.
author John Rouillard <rouilj@ieee.org>
date Thu, 08 Sep 2022 18:49:46 -0400
parents 3d2ec36541b9
children 3359dc1dabb0
comparison
equal deleted inserted replaced
6940:3d2ec36541b9 6941:bd2c3b2010c3
771 nodeid = None 771 nodeid = None
772 else: 772 else:
773 nodeid = self.matches['nodeid'] 773 nodeid = self.matches['nodeid']
774 774
775 # try in-reply-to to match the message if there's no nodeid 775 # try in-reply-to to match the message if there's no nodeid
776 # FIXME: possible crash if message linked to multiple issues 776 # If there are multiple matches for the in-reply-to, fall back
777 # Use the in-reply-to of the current message to find an id 777 # to title/subject match.
778 # for the message being replied to.
779 # Then search the current class (probably issue) for an issue
780 # that has the parent_message id in the issue's messages
781 # property. Then use this id as the node to update. HOWEVER if
782 # the reply to message is linked to multiple issues, I think
783 # this blows up.
784 # Linking a message to multiple issues can be used to group
785 # issues so that an update on a child issue is also reflected
786 # on a parent issue. As the parent and child may have different
787 # nosy/watchers.
788
789 inreplyto = self.message.get_header('in-reply-to') or '' 778 inreplyto = self.message.get_header('in-reply-to') or ''
790 if nodeid is None and inreplyto: 779 if nodeid is None and inreplyto:
791 parent_message = self.db.getclass('msg').stringFind( 780 parent_message = self.db.getclass('msg').stringFind(
792 messageid=inreplyto) 781 messageid=inreplyto)
793 # FIXME: if a message is linked to multiple issues, can nodeid
794 # be a list? If so, will this crash??
795 if parent_message: 782 if parent_message:
796 nodeid = self.cl.filter(None, 783 nodeid = self.cl.filter(None,
797 {'messages': parent_message})[0] 784 {'messages': parent_message})
798 785 if len(nodeid) == 1:
786 nodeid = nodeid[0]
787 elif nodeid: # len(nodeid) > 1
788 # This message is responding to a message
789 # we know about. But there is more than 1 issue
790 # associated with it.
791 # Before bouncing it or creating a new issue,
792 # force it to be treated as a reply even if the Subject
793 # is missing 'Re:'
794 # Note that multiple issues may be matched by
795 # Subject as well. The code chooses the most
796 # recently updated. Hopefully Subjects have
797 # less of a chance of collision. Possible future
798 # idea filter ids that match subject by id's
799 # that match in-reply-to and choose newest
800 # match. Not sure if this would work better in
801 # production, so not implementing now.
802 nodeid = None
803 # trigger Subject match
804 self.matches['refwd'] = True
805
799 # but we do need either a title or a nodeid... 806 # but we do need either a title or a nodeid...
800 if nodeid is None and not title: 807 if nodeid is None and not title:
801 raise MailUsageError(_(""" 808 raise MailUsageError(_("""
802 I cannot match your message to a node in the database - you need to either 809 I cannot match your message to a node in the database - you need to either
803 supply a full designator (with number, eg "[issue123]") or keep the 810 supply a full designator (with number, eg "[issue123]") or keep the

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