diff --git a/chat/indico_chat/notifications.py b/chat/indico_chat/notifications.py index 00d4023..6e8b00e 100644 --- a/chat/indico_chat/notifications.py +++ b/chat/indico_chat/notifications.py @@ -16,10 +16,8 @@ from __future__ import unicode_literals -from indico.core.config import Config +from indico.core.notifications import make_email, send_email from indico.core.plugins import get_plugin_template_module -from MaKaC.common.mail import GenericMailer -from MaKaC.webinterface.mail import GenericNotification def notify_created(room, event, user): @@ -30,7 +28,7 @@ def notify_created(room, event, user): :param user: the user performing the action """ tpl = get_plugin_template_module('emails/created.txt', chatroom=room, event=event, user=user) - _send(event, tpl.get_subject(), tpl.get_body()) + _send(event, tpl) def notify_attached(room, event, user): @@ -41,7 +39,7 @@ def notify_attached(room, event, user): :param user: the user performing the action """ tpl = get_plugin_template_module('emails/attached.txt', chatroom=room, event=event, user=user) - _send(event, tpl.get_subject(), tpl.get_body()) + _send(event, tpl) def notify_modified(room, event, user): @@ -52,7 +50,7 @@ def notify_modified(room, event, user): :param user: the user performing the action """ tpl = get_plugin_template_module('emails/modified.txt', chatroom=room, event=event, user=user) - _send(event, tpl.get_subject(), tpl.get_body()) + _send(event, tpl) def notify_deleted(room, event, user, room_deleted): @@ -65,19 +63,14 @@ def notify_deleted(room, event, user, room_deleted): """ tpl = get_plugin_template_module('emails/deleted.txt', chatroom=room, event=event, user=user, room_deleted=room_deleted) - _send(event, tpl.get_subject(), tpl.get_body()) + _send(event, tpl) -def _send(event, subject, body): +def _send(event, template_module): from indico_chat.plugin import ChatPlugin to_list = set(ChatPlugin.settings.get('notify_emails')) if not to_list: return - notification = { - 'fromAddr': Config.getInstance().getNoReplyEmail(), - 'toList': to_list, - 'subject': subject, - 'body': body - } - GenericMailer.sendAndLog(GenericNotification(notification), event, 'chat') + + send_email(make_email(to_list, template=template_module), event, 'Chat') diff --git a/chat/setup.py b/chat/setup.py index b74a7ed..2769d4e 100644 --- a/chat/setup.py +++ b/chat/setup.py @@ -21,7 +21,7 @@ from setuptools import setup, find_packages setup( name='indico_chat', - version='0.2', + version='0.3', url='https://github.com/indico/indico-plugins', license='https://www.gnu.org/licenses/gpl-3.0.txt', author='Indico Team', @@ -31,7 +31,7 @@ setup( include_package_data=True, platforms='any', install_requires=[ - 'indico>=1.9.2', + 'indico>=1.9.3', 'sleekxmpp' ], classifiers=[