[FIX] mail: correctly load livechat channels

The livechat channels returned by the chat_manager's initial RPC were ignored.
Livechat channels thus weren't persistent in the client action.

This rev. cleans the returned object 'channel_slots' so that it only contains
arrays of channels. The additional mapping and partners array were useless as
the information they contained was directly stored in the DM channels.

We now simply iterate on each array returned and add each channel it contains,
including livechat channels.
This commit is contained in:
Aaron Bohy
2015-11-20 15:48:03 +01:00
parent 1dfd1bd7a3
commit c2dfea5cc9
2 changed files with 3 additions and 9 deletions
-6
View File
@@ -467,12 +467,6 @@ class Channel(models.Model):
direct_message_channels = self.search([('channel_type', '=', 'chat'), ('id', 'in', pinned_channels.ids)])
values['channel_direct_message'] = direct_message_channels.channel_info()
# get the partner of the pinned 'direct message' channels with mapping partner/channel
direct_channel_partner = direct_message_channels.mapped('channel_last_seen_partner_ids').filtered(lambda cp: cp.partner_id.id != my_partner_id)
values['mapping'] = dict((item.partner_id.id, item.channel_id.id) for item in direct_channel_partner)
# partners of the 'direct message' channels
values['partners'] = direct_message_channels.mapped('channel_partner_ids').filtered(lambda partner: partner.id != my_partner_id).read(['id', 'name', 'im_status'])
# get the private group
values['channel_private_group'] = self.search([('channel_type', '=', 'channel'), ('public', '=', 'private'), ('channel_partner_ids', 'in', [my_partner_id])]).channel_info()
return values
+3 -3
View File
@@ -589,9 +589,9 @@ function init () {
});
var load_channels = session.rpc('/mail/client_action').then(function (result) {
_.each(result.channel_slots.channel_channel, add_channel);
_.each(result.channel_slots.channel_private_group, add_channel);
_.each(result.channel_slots.channel_direct_message, add_channel);
_.each(result.channel_slots, function (channels) {
_.each(channels, add_channel);
});
needaction_counter = result.needaction_inbox_counter;
});