Skip to content

Conversation

kyrias
Copy link
Contributor

@kyrias kyrias commented Oct 1, 2019

New iteration of #147.

@kyrias
Copy link
Contributor Author

kyrias commented Oct 1, 2019

With this implementation, the fully query-based mover ends up as just:

class QueryMailMover(AbstractMailMover):
    def __init__(self, max_age=0, *args, **kwargs):
        super(QueryMailMover, self).__init__(*args, **kwargs)
        self.query = '{subquery}'
        if max_age:
            days = timedelta(int(max_age))
            start = date.today() - days
            now = datetime.now()
            self.query += ' AND {start}..{now}'.format(start=start.strftime('%s'),
                                                       now=now.strftime('%s'))

    def find_matching(self, rule_name, query):
        main_query = self.query.format(subquery=query)
        for message in self.db.do_query(main_query).search_messages():
            for fname in [fname for fname in message.get_filenames()]:
                yield (message, fname)

@kyrias kyrias changed the title Abstract mailmover v2 Abstract out MailMover from mail selection Oct 1, 2019
@kyrias
Copy link
Contributor Author

kyrias commented Oct 1, 2019

Or, err, not, because apparently it doesn't work yet.

Nevermind, I had just forgotten to hook it up in main.py. It works the same way as the old version I've been using for a year or so. :)

@kyrias kyrias force-pushed the abstract-mailmover-v2 branch 3 times, most recently from 8719253 to 7efa7a2 Compare October 1, 2019 21:40
This allows implementing multiple move strategies.

Signed-off-by: Johannes Löthberg <[email protected]>
@kyrias kyrias force-pushed the abstract-mailmover-v2 branch from 7efa7a2 to 6eac6ea Compare November 15, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant