Commit 53b80186 authored by Jérome Perrin's avatar Jérome Perrin

Adjust Mail Message sending by activity

parent f4d41130
......@@ -135,19 +135,12 @@ if download or not use_activity:\n
context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n
\n
if use_activity:\n
destination_list = context.getDestinationValueList()\n
path_list = [x.getPath() for x in destination_list]\n
uid_list = [x.getUid() for x in destination_list]\n
method_kw = dict(event_relative_url=context.getRelativeUrl(),\n
from_url=from_url,\n
attachment_list=attachment_list)\n
from_url=from_url,\n
attachment_list=attachment_list)\n
context.activate(\n
after_path_and_method_id=(path_list, \n
# XXX Event_sendByActivity only applies to Mail Message at the moment.\n
# We should either renamted it to MailMessage_ or make this logic available to \n
# all kind of events.\n
(\'immediateReindexObject\', \'recursiveImmediateReindexObject\'))).Event_sendByActivity(\n
uid_list=uid_list,\n
after_path_and_method_id=((context.getPath(),), \n
(\'immediateReindexObject\', \'recursiveImmediateReindexObject\'))).MailMessage_sendByActivity(\n
method_kw=method_kw, **kw)\n
\n
if download:\n
......
......@@ -52,13 +52,13 @@
<key> <string>_body</string> </key>
<value> <string>context.getPortalObject().portal_catalog.searchAndActivate(\n
method_id="Entity_sendEmail",\n
uid=uid_list,\n
destination_related_uid=context.getUid(),\n
method_kw=method_kw, **kw)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>uid_list, method_kw, **kw</string> </value>
<value> <string>method_kw, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......@@ -70,7 +70,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Event_sendByActivity</string> </value>
<value> <string>MailMessage_sendByActivity</string> </value>
</item>
</dictionary>
</pickle>
......
1062
\ No newline at end of file
1064
\ No newline at end of file
......@@ -1764,28 +1764,34 @@ class TestCRMMailSend(BaseTestCRM):
self.tic()
mail_message = self.portal.event_module.newContent(portal_type="Mail Message")
relative_url_list = [z.getRelativeUrl() for z in self.portal.person_module.searchFolder()]
self.assertEquals(3, len(relative_url_list))
mail_message.setDestinationList(relative_url_list)
mail_message.setSource(relative_url_list[0])
mail_text_content = "Body Text Content"
mail_message.setTextContent(mail_text_content)
self.portal.portal_workflow.doActionFor(mail_message, "start_action")
self.tic()
mail_message.Event_send(packet_size=2)
# directly call MailMessage_send to pass a packet size of 1, so that we
# have one activity per recipient
mail_message.MailMessage_send(packet_size=1)
self.commit()
portal_activities = self.portal.portal_activities
portal_activities.manageInvoke(object_path=mail_message.getPath(), method_id='Event_sendByActivity')
portal_activities.manageInvoke(object_path=mail_message.getPath(),
method_id='immediateReindexObject')
portal_activities.manageInvoke(object_path=mail_message.getPath(),
method_id='MailMessage_sendByActivity')
self.commit()
message_list = [i for i in portal_activities.getMessageList() \
if i.kw.has_key("event_relative_url")]
try:
self.assertEquals(2, len(message_list))
# 3 recipients -> 3 activities
self.assertEquals(3, len(message_list))
finally:
self.tic()
last_message = self.portal.MailHost._last_message
self.assertTrue(mail_text_content in last_message[-1])
message = message_from_string(last_message[-1])
last_message_date = DateTime(message.get("Date"))
self.assertTrue(last_message_date.isCurrentDay())
self.assertEquals(3, len(self.portal.MailHost._message_list))
for message_info in self.portal.MailHost._message_list:
self.assertTrue(mail_text_content in message_info[-1])
message = message_from_string(message_info[-1])
self.assertTrue(DateTime(message.get("Date")).isCurrentDay())
def test_MailMessage_send_simple_case(self):
"""
......
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