[IMP] Add option to read e-mails unseen
parent
984b34e137
commit
a21f957229
|
@ -97,6 +97,10 @@ class FetchmailServerFolder(models.Model):
|
|||
help="Optional custom server action to trigger for each incoming "
|
||||
"mail, on the record that was created or updated by this mail",
|
||||
)
|
||||
fetch_unseen_only = fields.Boolean(
|
||||
help="By default all undeleted emails are searched. Checking this "
|
||||
"field adds the unread condition.",
|
||||
)
|
||||
|
||||
def button_confirm_folder(self):
|
||||
self.write({"state": "draft"})
|
||||
|
@ -170,10 +174,13 @@ class FetchmailServerFolder(models.Model):
|
|||
% {"folder": self.archive_path, "server": server.name}
|
||||
)
|
||||
|
||||
def get_criteria(self):
|
||||
return "UNDELETED" if not self.fetch_unseen_only else "UNSEEN UNDELETED"
|
||||
|
||||
def retrieve_imap_folder(self, connection):
|
||||
"""Retrieve all mails for one IMAP folder."""
|
||||
self.ensure_one()
|
||||
msgids = self.get_msgids(connection, "UNDELETED")
|
||||
msgids = self.get_msgids(connection, self.get_criteria())
|
||||
for msgid in msgids[0].split():
|
||||
# We will accept exceptions for single messages
|
||||
try:
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
<field name="active" />
|
||||
<field name="archive_path" />
|
||||
<field name="delete_matching" />
|
||||
<field name="fetch_unseen_only" />
|
||||
<field name="msg_state" />
|
||||
</group>
|
||||
</group>
|
||||
|
|
|
@ -42,7 +42,7 @@ class AttachMailManually(models.TransientModel):
|
|||
folder = folder_model.browse([folder_id])
|
||||
connection = folder.server_id.connect()
|
||||
connection.select(folder.path)
|
||||
criteria = "FLAGGED" if folder.flag_nonmatching else "UNDELETED"
|
||||
criteria = "FLAGGED" if folder.flag_nonmatching else folder.get_criteria()
|
||||
msgids = folder.get_msgids(connection, criteria)
|
||||
for msgid in msgids[0].split():
|
||||
mail_message, message_org = folder.fetch_msg(connection, msgid)
|
||||
|
|
Loading…
Reference in New Issue