Extend handling of GMail labels header
Format headers X-Label and Keywords as a space separated list and all other ones as comma-separated entities. This makes OfflineIMAP label handling to be compatible with some user agents that recognise these headers. Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:

committed by
Eygene Ryabinkin

parent
0e4afa9132
commit
789e047734
@ -92,8 +92,8 @@ class GmailFolder(IMAPFolder):
|
||||
else:
|
||||
labels = set()
|
||||
labels = labels - self.ignorelabels
|
||||
labels = ', '.join(sorted(labels))
|
||||
body = self.addmessageheader(body, self.labelsheader, labels)
|
||||
labels_str = imaputil.format_labels_string(self.labelsheader, sorted(labels))
|
||||
body = self.addmessageheader(body, self.labelsheader, labels_str)
|
||||
|
||||
if len(body)>200:
|
||||
dbg_output = "%s...%s" % (str(body)[:150], str(body)[-50:])
|
||||
@ -183,11 +183,8 @@ class GmailFolder(IMAPFolder):
|
||||
if not self.synclabels:
|
||||
return super(GmailFolder, self).savemessage(uid, content, flags, rtime)
|
||||
|
||||
labels = self.getmessageheader(content, self.labelsheader)
|
||||
if labels:
|
||||
labels = set([lb.strip() for lb in labels.split(',') if len(lb.strip()) > 0])
|
||||
else:
|
||||
labels = set()
|
||||
labels = imaputil.labels_from_header(self.labelsheader,
|
||||
self.getmessageheader(content, self.labelsheader))
|
||||
|
||||
ret = super(GmailFolder, self).savemessage(uid, content, flags, rtime)
|
||||
self.savemessagelabels(ret, labels)
|
||||
|
Reference in New Issue
Block a user