fixed issue 1638:imap: content as list field type and other small changes, thanks Alan
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.6.0-development+timestamp.2013.08.20.11.14.41
|
Version 2.6.0-development+timestamp.2013.08.21.02.33.07
|
||||||
|
|||||||
+24
-23
@@ -5836,7 +5836,7 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
uid string
|
uid string
|
||||||
answered boolean Flag
|
answered boolean Flag
|
||||||
created date
|
created date
|
||||||
content list:string A list of text or html parts
|
content list:string A list of dict text or html parts
|
||||||
to string
|
to string
|
||||||
cc string
|
cc string
|
||||||
bcc string
|
bcc string
|
||||||
@@ -5978,8 +5978,9 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
|
|
||||||
""" MESSAGE is an identifier for sequence number"""
|
""" MESSAGE is an identifier for sequence number"""
|
||||||
|
|
||||||
self.flags = ['\\Deleted', '\\Draft', '\\Flagged',
|
self.flags = {'deleted': '\\Deleted', 'draft': '\\Draft',
|
||||||
'\\Recent', '\\Seen', '\\Answered']
|
'flagged': '\\Flagged', 'recent': '\\Recent',
|
||||||
|
'seen': '\\Seen', 'answered': '\\Answered'}
|
||||||
self.search_fields = {
|
self.search_fields = {
|
||||||
'id': 'MESSAGE', 'created': 'DATE',
|
'id': 'MESSAGE', 'created': 'DATE',
|
||||||
'uid': 'UID', 'sender': 'FROM',
|
'uid': 'UID', 'sender': 'FROM',
|
||||||
@@ -6202,7 +6203,7 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
return tablename
|
return tablename
|
||||||
|
|
||||||
def is_flag(self, flag):
|
def is_flag(self, flag):
|
||||||
if self.search_fields.get(flag, None) in self.flags:
|
if self.search_fields.get(flag, None) in self.flags.values():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@@ -6234,7 +6235,7 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
Field("uid", "string", writable=False),
|
Field("uid", "string", writable=False),
|
||||||
Field("answered", "boolean"),
|
Field("answered", "boolean"),
|
||||||
Field("created", "datetime", writable=False),
|
Field("created", "datetime", writable=False),
|
||||||
Field("content", "list:string", writable=False),
|
Field("content", list, writable=False),
|
||||||
Field("to", "string", writable=False),
|
Field("to", "string", writable=False),
|
||||||
Field("cc", "string", writable=False),
|
Field("cc", "string", writable=False),
|
||||||
Field("bcc", "string", writable=False),
|
Field("bcc", "string", writable=False),
|
||||||
@@ -6451,23 +6452,23 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
maintype = part.get_content_maintype()
|
maintype = part.get_content_maintype()
|
||||||
if ("%s.attachments" % tablename in colnames) or \
|
if ("%s.attachments" % tablename in colnames) or \
|
||||||
("%s.content" % tablename in colnames):
|
("%s.content" % tablename in colnames):
|
||||||
if "%s.attachments" % tablename in colnames:
|
payload = part.get_payload(decode=True)
|
||||||
if not ("text" in maintype):
|
if payload:
|
||||||
payload = part.get_payload(decode=True)
|
filename = part.get_filename()
|
||||||
if payload:
|
values = {"mime": part.get_content_type()}
|
||||||
attachment = {
|
if ((filename or not "text" in maintype) and
|
||||||
"payload": payload,
|
("%s.attachments" % tablename in colnames)):
|
||||||
"filename": part.get_filename(),
|
values.update({"payload": payload,
|
||||||
"encoding": part.get_content_charset(),
|
"filename": filename,
|
||||||
"mime": part.get_content_type(),
|
"encoding": part.get_content_charset(),
|
||||||
"disposition": part["Content-Disposition"]}
|
"disposition": part["Content-Disposition"]})
|
||||||
attachments.append(attachment)
|
attachments.append(values)
|
||||||
if "%s.content" % tablename in colnames:
|
elif (("text" in maintype) and
|
||||||
payload = part.get_payload(decode=True)
|
("%s.content" % tablename in colnames)):
|
||||||
part_charset = self.get_charset(part)
|
values.update({"text": self.encode_text(payload,
|
||||||
if "text" in maintype:
|
self.get_charset(part))})
|
||||||
if payload:
|
content.append(values)
|
||||||
content.append(self.encode_text(payload, part_charset))
|
|
||||||
if "%s.size" % tablename in colnames:
|
if "%s.size" % tablename in colnames:
|
||||||
if part is not None:
|
if part is not None:
|
||||||
size += len(str(part))
|
size += len(str(part))
|
||||||
@@ -6787,7 +6788,7 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
elif name == "DATE":
|
elif name == "DATE":
|
||||||
result = "ON %s" % self.convert_date(second)
|
result = "ON %s" % self.convert_date(second)
|
||||||
|
|
||||||
elif name in self.flags:
|
elif name in self.flags.values():
|
||||||
if second:
|
if second:
|
||||||
result = "%s" % (name.upper()[1:])
|
result = "%s" % (name.upper()[1:])
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user