Commit 997ab603 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_base: use type based method to retrieve method to create posts

parent 9aabdd74
...@@ -29,18 +29,8 @@ mail_message = portal.Base_createMailMessageAsString( ...@@ -29,18 +29,8 @@ mail_message = portal.Base_createMailMessageAsString(
embedded_file_list=embedded_file_list, embedded_file_list=embedded_file_list,
extra_header_dict=extra_header_dict) extra_header_dict=extra_header_dict)
internet_message_post_module = portal.getDefaultModuleValue('Internet Message Post', None) create_post_message_method = event.getTypeBasedMethod('createPostMessage')
if internet_message_post_module is not None: if create_post_message_method:
# erp5_interface_post is installed, so it is needed to track outgoing emails create_post_message_method(mail_message)
internet_message_post = internet_message_post_module.newContent(
portal_type='Internet Message Post',
title="Internet Message for %s" % event.getTitle(),
reference=event.getReference(),
data=mail_message,
)
internet_message_post.allowExport()
event_aggregate_list = event.getAggregateList()
event_aggregate_list.append(internet_message_post.getRelativeUrl())
event.setAggregateList(event_aggregate_list)
else: else:
event.sendMailHostMessage(mail_message) event.sendMailHostMessage(mail_message)
...@@ -47,6 +47,9 @@ if not context.hasStartDate(): ...@@ -47,6 +47,9 @@ if not context.hasStartDate():
context.setStartDate(DateTime()) context.setStartDate(DateTime())
if download or not use_activity: if download or not use_activity:
create_post_message_method = context.getTypeBasedMethod('createPostMessage')
for to_url in to_url_list: for to_url in to_url_list:
body = body or context.getTextContent() or '' body = body or context.getTextContent() or ''
subject = subject or context.getTitle() or '' subject = subject or context.getTitle() or ''
...@@ -79,20 +82,8 @@ if download or not use_activity: ...@@ -79,20 +82,8 @@ if download or not use_activity:
embedded_file_list=embedded_file_list, embedded_file_list=embedded_file_list,
extra_header_dict=extra_header_dict) extra_header_dict=extra_header_dict)
internet_message_post_module = portal.getDefaultModuleValue('Internet Message Post', None) if create_post_message_method:
if internet_message_post_module is not None: create_post_message_method(mail_message)
# erp5_interface_post is installed, so it is needed to track outgoing emails
internet_message_post = internet_message_post_module.newContent(
portal_type='Internet Message Post',
title="Internet Message for %s" % context.getTitle(),
reference=context.getReference(),
data=mail_message,
)
internet_message_post.allowExport()
mail_aggregate_list = context.getAggregateList()
mail_aggregate_list.append(internet_message_post.getRelativeUrl())
context.setAggregateList(mail_aggregate_list)
else: else:
if not use_activity: if not use_activity:
context.activate(activity='SQLQueue').sendMailHostMessage(mail_message) context.activate(activity='SQLQueue').sendMailHostMessage(mail_message)
......
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