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