mirror of
https://github.com/pulb/mailnag.git
synced 2026-05-06 22:37:14 +02:00
Some more fixes for mailbox related mark as seen
This commit is contained in:
@@ -144,11 +144,15 @@ class IMAPMailboxBackend(MailboxBackend):
|
||||
|
||||
for m in sorted_mails:
|
||||
if ('uid' in m.flags) and ('folder' in m.flags):
|
||||
folder = m.flags['folder']
|
||||
if folder != last_folder:
|
||||
conn.select(f'"{folder}"', readonly = False)
|
||||
last_folder = folder
|
||||
status, data = conn.uid("STORE", m.flags['uid'], "+FLAGS", "(\Seen)")
|
||||
try:
|
||||
folder = m.flags['folder']
|
||||
if folder != last_folder:
|
||||
conn.select(f'"{folder}"', readonly = False)
|
||||
last_folder = folder
|
||||
status, data = conn.uid("STORE", m.flags['uid'], "+FLAGS", "(\Seen)")
|
||||
except:
|
||||
logging.warning("Failed to set mail with uid %s to seen on server (account: '%s').", m.flags['uid'], acc.name)
|
||||
|
||||
finally:
|
||||
self._disconnect(conn)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2011 - 2019 Patrick Ulbrich <zulu99@gmx.net>
|
||||
# Copyright 2011 - 2020 Patrick Ulbrich <zulu99@gmx.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -23,11 +23,12 @@ from configparser import RawConfigParser
|
||||
mailnag_defaults = {
|
||||
'core':
|
||||
{
|
||||
'poll_interval' : '10',
|
||||
'imap_idle_timeout' : '10',
|
||||
'autostart' : '1',
|
||||
'connectivity_test' : 'auto',
|
||||
'enabled_plugins' : 'dbusplugin, soundplugin, libnotifyplugin'
|
||||
'poll_interval' : '10',
|
||||
'imap_idle_timeout' : '10',
|
||||
'mailbox_seen_flags' : '1',
|
||||
'autostart' : '1',
|
||||
'connectivity_test' : 'auto',
|
||||
'enabled_plugins' : 'dbusplugin, soundplugin, libnotifyplugin'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ class MailChecker:
|
||||
self._firstcheck = True # first check after startup
|
||||
self._mailcheck_lock = threading.Lock()
|
||||
self._mailsyncer = MailSyncer(cfg)
|
||||
self._mailbox_seen_flags = bool(cfg.get('core', 'mailbox_seen_flags'))
|
||||
self._memorizer = memorizer
|
||||
self._hookreg = hookreg
|
||||
self._conntest = conntest
|
||||
@@ -63,7 +64,7 @@ class MailChecker:
|
||||
unseen_mails.append(mail)
|
||||
if self._firstcheck:
|
||||
new_mails.append(mail)
|
||||
else:
|
||||
elif self._mailbox_seen_flags:
|
||||
# if the mail account supports tagging mails as seen (e.g. IMAP),
|
||||
# mark the mail as seen on the server as well.
|
||||
if mail.account.supports_mark_as_seen():
|
||||
@@ -76,10 +77,7 @@ class MailChecker:
|
||||
|
||||
# Flag mails to seen on server
|
||||
for acc, mails in seen_mails_by_account.items():
|
||||
try:
|
||||
acc.mark_as_seen(mails)
|
||||
except:
|
||||
logging.warning("Failed to set mails to seen on server (account: '%s').", acc.name)
|
||||
acc.mark_as_seen(mails)
|
||||
|
||||
self._memorizer.sync(all_mails)
|
||||
self._memorizer.save()
|
||||
|
||||
Reference in New Issue
Block a user