[IMP] mail: remove uuid from channel_fold

Unnecessary param.

task-2827807

closes odoo/odoo#89115

Related: odoo/enterprise#26388
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2022-04-21 12:49:58 +02:00
parent 870eb515eb
commit ccdda4450c
4 changed files with 30 additions and 32 deletions
+3 -4
View File
@@ -936,14 +936,13 @@ class Channel(models.Model):
channel._broadcast(partners_to)
return channel.channel_info()[0]
@api.model
def channel_fold(self, uuid, state=None):
def channel_fold(self, state=None):
""" Update the fold_state of the given session. In order to syncronize web browser
tabs, the change will be broadcast to himself (the current user channel).
Note: the user need to be logged
:param state : the new status of the session for the current user.
"""
domain = [('partner_id', '=', self.env.user.partner_id.id), ('channel_id.uuid', '=', uuid)]
domain = [('partner_id', '=', self.env.user.partner_id.id), ('channel_id', 'in', self.ids)]
for session_state in self.env['mail.channel.partner'].search(domain):
if not state:
state = session_state.fold_state
@@ -960,7 +959,7 @@ class Channel(models.Model):
if vals:
session_state.write(vals)
self.env['bus.bus']._sendone(self.env.user.partner_id, 'mail.channel/insert', {
'id': session_state.channel_id.channel_info()[0]['id'],
'id': session_state.channel_id.id,
'serverFoldState': state,
})
+4 -7
View File
@@ -388,16 +388,16 @@ registerModel({
/**
* Performs the `channel_fold` RPC on `mail.channel`.
*
* @param {string} uuid
* @param {number} channelId
* @param {string} state
*/
async performRpcChannelFold(uuid, state) {
async performRpcChannelFold(channelId, state) {
return this.env.services.rpc({
model: 'mail.channel',
method: 'channel_fold',
args: [[channelId]],
kwargs: {
state,
uuid,
}
}, { shadow: true });
},
@@ -875,10 +875,7 @@ registerModel({
// Server sync of fold state is only supported for channels.
return;
}
if (!this.uuid) {
return;
}
return this.messaging.models['Thread'].performRpcChannelFold(this.uuid, state);
return this.messaging.models['Thread'].performRpcChannelFold(this.id, state);
},
/**
* Notify server to leave the current channel. Useful for cross-tab
+21 -19
View File
@@ -171,9 +171,9 @@ MockServer.include({
return this._mockMailChannelChannelFetchPreview(ids);
}
if (args.model === 'mail.channel' && args.method === 'channel_fold') {
const uuid = args.args[0] || args.kwargs.uuid;
const ids = args.args[0];
const state = args.args[1] || args.kwargs.state;
return this._mockMailChannelChannelFold(uuid, state);
return this._mockMailChannelChannelFold(ids, state);
}
if (args.model === 'mail.channel' && args.method === 'channel_get') {
const partners_to = args.args[0] || args.kwargs.partners_to;
@@ -871,25 +871,27 @@ MockServer.include({
* In particular sends a notification on the bus.
*
* @private
* @param {string} uuid
* @param {number} ids
* @param {state} [state]
*/
_mockMailChannelChannelFold(uuid, state) {
const channel = this._getRecords('mail.channel', [['uuid', '=', uuid]])[0];
const [memberOfCurrentUser] = this._getRecords('mail.channel.partner', [['channel_id', '=', channel.id], ['partner_id', '=', this.currentPartnerId]]);
const foldState = state ? state : memberOfCurrentUser.fold_state === 'open' ? 'folded' : 'open';
const vals = {
fold_state: foldState,
is_minimized: foldState !== 'closed',
};
this._mockWrite('mail.channel.partner', [[memberOfCurrentUser.id], vals]);
this._widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel/insert',
payload: {
id: channel.id,
serverFoldState: memberOfCurrentUser.fold_state,
},
}]);
_mockMailChannelChannelFold(ids, state) {
const channels = this._getRecords('mail.channel', [['id', 'in', ids]]);
for (const channel of channels) {
const [memberOfCurrentUser] = this._getRecords('mail.channel.partner', [['channel_id', '=', channel.id], ['partner_id', '=', this.currentPartnerId]]);
const foldState = state ? state : memberOfCurrentUser.fold_state === 'open' ? 'folded' : 'open';
const vals = {
fold_state: foldState,
is_minimized: foldState !== 'closed',
};
this._mockWrite('mail.channel.partner', [[memberOfCurrentUser.id], vals]);
this._widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel/insert',
payload: {
id: channel.id,
serverFoldState: memberOfCurrentUser.fold_state,
},
}]);
}
},
/**
* Simulates 'channel_get' on 'mail.channel'.
@@ -520,7 +520,7 @@ QUnit.test('chat window: fold', async function (assert) {
assert.expect(9);
const pyEnv = await startServer();
pyEnv['mail.channel'].create({ uuid: 'channel-uuid' });
pyEnv['mail.channel'].create({});
const { click, createMessagingMenuComponent } = await this.start({
mockRPC(route, args) {
if (args.method === 'channel_fold') {
@@ -572,7 +572,7 @@ QUnit.test('chat window: open / close', async function (assert) {
assert.expect(10);
const pyEnv = await startServer();
pyEnv['mail.channel'].create({ uuid: 'channel-uuid' });
pyEnv['mail.channel'].create({});
const { click, createMessagingMenuComponent } = await this.start({
mockRPC(route, args) {
if (args.method === 'channel_fold') {