diff --git a/web_notify_channel_message/README.rst b/web_notify_channel_message/README.rst new file mode 100644 index 000000000..e69de29bb diff --git a/web_notify_channel_message/__init__.py b/web_notify_channel_message/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/web_notify_channel_message/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_notify_channel_message/__manifest__.py b/web_notify_channel_message/__manifest__.py new file mode 100644 index 000000000..ffe9b5aea --- /dev/null +++ b/web_notify_channel_message/__manifest__.py @@ -0,0 +1,16 @@ +# pylint: disable=missing-docstring +# Copyright 2023 ForgeFlow, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Web Notify Channel Message", + "summary": """ + Send an instant notification to channel users when a new message is posted""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "development_status": "Alpha", + "website": "https://github.com/OCA/web", + "depends": ["web_notify", "mail"], + "installable": True, +} diff --git a/web_notify_channel_message/models/__init__.py b/web_notify_channel_message/models/__init__.py new file mode 100644 index 000000000..3ce7ca7fe --- /dev/null +++ b/web_notify_channel_message/models/__init__.py @@ -0,0 +1 @@ +from . import mail_channel diff --git a/web_notify_channel_message/models/mail_channel.py b/web_notify_channel_message/models/mail_channel.py new file mode 100644 index 000000000..ce1c55772 --- /dev/null +++ b/web_notify_channel_message/models/mail_channel.py @@ -0,0 +1,21 @@ +# pylint: disable=missing-docstring +# Copyright 2016 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, models + + +class MailChannel(models.Model): + _inherit = "mail.channel" + + def message_post(self, *, message_type="notification", **kwargs): + message = super().message_post(message_type=message_type, **kwargs) + for partner in self.channel_partner_ids: + users = partner.user_ids + for user in users: + if user in message.author_id.user_ids: + continue + user.notify_info( + message=_("You have a new message in channel %s") % self.name + ) + return message diff --git a/web_notify_channel_message/readme/CONTRIBUTORS.rst b/web_notify_channel_message/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..56ac1356f --- /dev/null +++ b/web_notify_channel_message/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Joan Sisquella +* Thiago Mulero +* David Jimenez +* Jordi Ballester diff --git a/web_notify_channel_message/readme/DESCRIPTION.rst b/web_notify_channel_message/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ddb6ae81f --- /dev/null +++ b/web_notify_channel_message/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module will send an instant notifications to all users of a channel when a new message has been posted.