<DKIM> [PATCH 2/3] IMAP folder: expose the message keywords

Igor Almeida igor.contato at gmail.com
Sun Nov 8 18:50:44 GMT 2015


Hi,

Thanks for reviewing. Comments below

On 11/07/2015 02:52 PM, Nicolas Sebrecht wrote:
> On Sat, Nov 07, 2015 at 11:16:54AM -0300, Igor Almeida wrote:
> 
>> The keywords are in the flag string, so imaputil can just strip the
>> usual \Flags.
>>
>> Signed-off-by: Igor Almeida <igor.contato at gmail.com>
>> ---
>>  offlineimap/folder/Base.py | 5 +++++
>>  offlineimap/folder/IMAP.py | 8 +++++++-
>>  offlineimap/imaputil.py    | 8 ++++++++
>>  3 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
>> index d2a0706..5031a40 100644
>> --- a/offlineimap/folder/Base.py
>> +++ b/offlineimap/folder/Base.py
>> @@ -420,6 +420,11 @@ class BaseFolder(object):
>>  
>>          raise NotImplementedError
>>  
>> +    def getmessagekeywords(self, uid):
>> +        """Returns the keywords for the specified message."""
>> +
>> +        raise NotImplementedError
>> +
>>      def savemessageflags(self, uid, flags):
>>          """Sets the specified message's flags to the given set.
>>  
>> diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
>> index 60b5301..7f0fd6d 100644
>> --- a/offlineimap/folder/IMAP.py
>> +++ b/offlineimap/folder/IMAP.py
>> @@ -251,8 +251,10 @@ class IMAPFolder(BaseFolder):
>>                  uid = long(options['UID'])
>>                  self.messagelist[uid] = self.msglist_item_initializer(uid)
>>                  flags = imaputil.flagsimap2maildir(options['FLAGS'])
>> +                keywords = imaputil.flagsimap2keywords(options['FLAGS'])
>>                  rtime = imaplibutil.Internaldate2epoch(messagestr)
>> -                self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime}
>> +                self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime,
>> +                    'keywords': keywords}
> 
> The IMAP server may not accept the provided keywords.
> 
Are you talking about an IMAP -> IMAP sync? If so, that could be true
for the destination server, but this patchset does not implement this
use case.
In my use case, IMAP -> Maildir, the flags are already there and we're
just translating them to lower-case letters.

> I can think of 3 cases right now:
> - the server don't allow Keywords at all;
> - the server only allow pre-defined Keywords;
> - the server allows creating new Keywords (see PERMANTENTFLAGS).
> 
> I guess it's fine to assume that Keywords are permanents for now, but we
> have to check if the server allows creating new Keywords. Otherwise, the
> server will reply with 'NO' to commands like APPEND.
> 
> IOW, we have to honor PERMANTENTFLAGS cleanly.
> 

-- 
Igor Almeida




More information about the OfflineIMAP-project mailing list