diff options
-rw-r--r-- | distixlib/plugins/import_mail_plugin.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/distixlib/plugins/import_mail_plugin.py b/distixlib/plugins/import_mail_plugin.py index dc13da8..6fc131b 100644 --- a/distixlib/plugins/import_mail_plugin.py +++ b/distixlib/plugins/import_mail_plugin.py @@ -172,20 +172,21 @@ class ImportMailPlugin(cliapp.Plugin): msg_ids = distixlib.get_ids_from_message(msg) for ticket_id in context.all_ticket_ids: - if ticket_id in context.cache: - other_ids = contex.cache.get_msg_ids_for_ticket_id(ticket_id) - else: - filenames = context.store.get_message_filenames(ticket_id) - for filename in filenames: - other_msg = self._read_mail_message(filename) - other_ids = distixlib.get_ids_from_message(other_msg) - context.cache.add_msg_ids_for_ticket_id( - ticket_id, other_ids) + other_ids = self._get_ticket_message_ids(context, ticket_id) if other_ids.intersection(msg_ids): ticket_ids.append(ticket_id) return ticket_ids + def _get_ticket_message_ids(self, context, ticket_id): + if ticket_id not in context.cache: + filenames = context.store.get_message_filenames(ticket_id) + for filename in filenames: + msg = self._read_mail_message(filename) + msg_ids = distixlib.get_ids_from_message(msg) + context.cache.add_msg_ids_for_ticket_id(ticket_id, msg_ids) + return context.cache.get_msg_ids_for_ticket_id(ticket_id) + def _create_ticket_from_msg(self, repo, msg): ticket_id = repo.invent_new_ticket_id() subject = self._get_header(msg, 'Subject') |