Commit 50d79dcc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

do not store aggregated documents in Email document to avoid duplicate data.

parent 4140566d
...@@ -83,7 +83,18 @@ mail_message = context.Base_createMailMessageAsString(from_url,\n ...@@ -83,7 +83,18 @@ mail_message = context.Base_createMailMessageAsString(from_url,\n
event.sendMailHostMessage(mail_message)\n event.sendMailHostMessage(mail_message)\n
\n \n
if not event.hasData():\n if not event.hasData():\n
event.setData(mail_message)\n if len(embedded_file_list):\n
# do not store aggregated documents in Email document\n
# to avoid duplicate data\n
tmp_mail_message = context.Base_createMailMessageAsString(from_url,\n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list)\n
event.setData(tmp_mail_message)\n
else:\n
event.setData(mail_message)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -110,7 +110,18 @@ if download or not use_activity:\n ...@@ -110,7 +110,18 @@ if download or not use_activity:\n
attachment_list=attachment_list,\n attachment_list=attachment_list,\n
embedded_file_list=embedded_file_list)\n embedded_file_list=embedded_file_list)\n
\n \n
context.edit(data=mail_message)\n if len(embedded_file_list):\n
# do not store aggregated documents in Email document\n
# to avoid duplicate data\n
tmp_mail_message = context.Base_createMailMessageAsString(from_url,\n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list)\n
context.setData(tmp_mail_message)\n
else:\n
context.setData(mail_message)\n
if not use_activity:\n if not use_activity:\n
context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n
\n \n
......
1041 1042
\ No newline at end of file \ No newline at end of file
...@@ -665,6 +665,7 @@ class EmailDocument(TextDocument): ...@@ -665,6 +665,7 @@ class EmailDocument(TextDocument):
if attachment_list is None: if attachment_list is None:
attachment_list = [] attachment_list = []
document_type_list = self.getPortalDocumentTypeList() document_type_list = self.getPortalDocumentTypeList()
embedded_attachment_list = []
for attachment in self.getAggregateValueList(): for attachment in self.getAggregateValueList():
mime_type = None mime_type = None
content = None content = None
...@@ -704,7 +705,7 @@ class EmailDocument(TextDocument): ...@@ -704,7 +705,7 @@ class EmailDocument(TextDocument):
if not isinstance(content, str): if not isinstance(content, str):
content = str(content) content = str(content)
attachment_list.append({'mime_type':mime_type, embedded_attachment_list.append({'mime_type':mime_type,
'content':content, 'content':content,
'name':attachment.getReference()} 'name':attachment.getReference()}
) )
...@@ -713,14 +714,24 @@ class EmailDocument(TextDocument): ...@@ -713,14 +714,24 @@ class EmailDocument(TextDocument):
for to_url in to_url_list: for to_url in to_url_list:
mime_message = buildEmailMessage(from_url=from_url, to_url=to_url, mime_message = buildEmailMessage(from_url=from_url, to_url=to_url,
msg=body, subject=subject, msg=body, subject=subject,
attachment_list=attachment_list, attachment_list=(attachment_list + embedded_attachment_list),
additional_headers=additional_headers) additional_headers=additional_headers)
mail_message = mime_message.as_string() mail_message = mime_message.as_string()
self.activate(activity='SQLQueue').sendMailHostMessage(mail_message) self.activate(activity='SQLQueue').sendMailHostMessage(mail_message)
# Save one of mail messages. # Save one of mail messages.
if mail_message is not None: if mail_message is not None:
self.setData(mail_message) if len(embedded_attachment_list):
# do not store aggregated documents in Email document
# to avoid duplicate data
tmp_mime_message = buildEmailMessage(from_url=from_url, to_url=to_url,
msg=body, subject=subject,
attachment_list=attachment_list,
additional_headers=additional_headers)
tmp_mail_message = mime_message.as_string()
self.setData(tmp_mail_message)
else:
self.setData(mail_message)
# Only for debugging purpose # Only for debugging purpose
if download: if download:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment