summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2015-10-19 11:20:02 +0200
committerGéry Debongnie <ged@odoo.com>2015-10-22 14:43:13 +0200
commit586928356b5cff88e11fac421ff2b34568c9d17a (patch)
tree2412d59c6a0e5be23ec522a98c3ac04a6df887b4
parent81b7a32a4dca67bc02559b985fe9e925e7708f6d (diff)
[IMP] mail: notifies users when someone join/leave a channel
-rw-r--r--addons/mail/models/mail_channel.py12
-rw-r--r--addons/mail/static/src/js/chat_manager.js3
2 files changed, 9 insertions, 6 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index fb5bc04c160..22f5249c973 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -145,7 +145,11 @@ class Channel(models.Model):
@api.multi
def action_unfollow(self):
- return self.write({'channel_partner_ids': [(3, self.env.user.partner_id.id)]})
+ result = self.write({'channel_partner_ids': [(3, self.env.user.partner_id.id)]})
+ self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), self.channel_info()[0])
+ notification = _('<div class="o_mail_notification">left <a href="#" data-channel-id="%s">#%s</a></div>') % (self.uuid, self.name,)
+ self.message_post(body=notification, message_type="comment", subtype="mail.mt_comment")
+ return result
@api.multi
@@ -481,8 +485,8 @@ class Channel(models.Model):
@api.multi
def channel_join_and_get_info(self):
self.ensure_one()
- notification = {"type": "user_join", "payload": {"channel_id": self.id, "name": self.env.user.partner_id.name}}
- self.env['bus.bus'].sendmany([[(self._cr.dbname, 'mail.channel', self.id), notification]])
+ notification = _('<div class="o_mail_notification">joined <a href="#" data-channel-id="%s">#%s</a></div>') % (self.uuid, self.name,)
+ self.message_post(body=notification, message_type="notification", subtype="mail.mt_comment")
self.action_follow()
channel_info = self.channel_info()[0]
@@ -505,5 +509,7 @@ class Channel(models.Model):
'channel_partner_ids': [(4, self.env.user.partner_id.id)]
})
channel_info = new_channel.channel_info()[0]
+ notification = _('<div class="o_mail_notification">created <a href="#" data-channel-id="%s">#%s</a></div>') % (new_channel.uuid, new_channel.name,)
+ new_channel.message_post(body=notification, message_type="notification", subtype="mail.mt_comment")
self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), channel_info)
return channel_info
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js
index 7064a2bfb6d..4e8e75f7840 100644
--- a/addons/mail/static/src/js/chat_manager.js
+++ b/addons/mail/static/src/js/chat_manager.js
@@ -457,9 +457,6 @@ function init () {
if (model === 'mail.channel') {
// new message in a channel
var message = notification[1];
- if (message.type === 'user_join') {
- return; // to be implemented later
- }
var channel_id = message.channel_ids[0];
// fetch the channel info if not done already
var channel = _.findWhere(channels, {id: channel_id});