[IMP] mail, *: remove uuid from channel_pin

* = im_livechat, website_livechat

Unnecessary param.

task-2827807

Part-of: odoo/odoo#89115
This commit is contained in:
Sébastien Theys
2022-04-21 12:49:58 +02:00
parent d67e1e4b8f
commit 870eb515eb
5 changed files with 14 additions and 21 deletions
@@ -350,7 +350,7 @@ class ChatbotScriptStep(models.Model):
Markup('<div class="o_mail_notification">%s</div>') % _('%s has joined', human_operator.partner_id.name))
mail_channel._broadcast(human_operator.partner_id.ids)
mail_channel.channel_pin(mail_channel.uuid, pinned=True)
mail_channel.channel_pin(pinned=True)
return posted_message
+2 -9
View File
@@ -964,14 +964,7 @@ class Channel(models.Model):
'serverFoldState': state,
})
@api.model
def channel_pin(self, uuid, pinned=False):
# add the person in the channel, and pin it (or unpin it)
channel = self.search([('uuid', '=', uuid)])
channel._execute_channel_pin(pinned)
def _execute_channel_pin(self, pinned=False):
""" Hook for website_livechat channel unpin and cleaning """
def channel_pin(self, pinned=False):
self.ensure_one()
channel_partners = self.env['mail.channel.partner'].search(
[('partner_id', '=', self.env.user.partner_id.id), ('channel_id', '=', self.id), ('is_pinned', '!=', pinned)])
@@ -1267,7 +1260,7 @@ class Channel(models.Model):
if self.channel_type in ('channel', 'group'):
self.action_unfollow()
else:
self.channel_pin(self.uuid, False)
self.channel_pin(False)
def execute_command_who(self, **kwargs):
partner = self.env.user.partner_id
+4 -4
View File
@@ -439,15 +439,15 @@ registerModel({
* Performs the `channel_pin` RPC on `mail.channel`.
*
* @param {Object} param0
* @param {number} param0.channelId
* @param {boolean} [param0.pinned=false]
* @param {string} param0.uuid
*/
async performRpcChannelPin({ pinned = false, uuid }) {
async performRpcChannelPin({ channelId, pinned = false }) {
return this.env.services.rpc({
model: 'mail.channel',
method: 'channel_pin',
args: [[channelId]],
kwargs: {
uuid,
pinned,
},
}, { shadow: true });
@@ -892,8 +892,8 @@ registerModel({
return;
}
await this.messaging.models['Thread'].performRpcChannelPin({
channelId: this.id,
pinned: this.isPendingPinned,
uuid: this.uuid,
});
},
/**
@@ -194,9 +194,9 @@ MockServer.include({
return this._mockMailChannelAddMembers(ids, partner_ids);
}
if (args.model === 'mail.channel' && args.method === 'channel_pin') {
const uuid = args.args[0] || args.kwargs.uuid;
const ids = args.args[0];
const pinned = args.args[1] || args.kwargs.pinned;
return this._mockMailChannelChannelPin(uuid, pinned);
return this._mockMailChannelChannelPin(ids, pinned);
}
if (args.model === 'mail.channel' && args.method === 'channel_rename') {
const ids = args.args[0];
@@ -986,11 +986,11 @@ MockServer.include({
* Simulates the `channel_pin` method of `mail.channel`.
*
* @private
* @param {string} uuid
* @param {number[]} ids
* @param {boolean} [pinned=false]
*/
async _mockMailChannelChannelPin(uuid, pinned = false) {
const channel = this._getRecords('mail.channel', [['uuid', '=', uuid]])[0];
async _mockMailChannelChannelPin(ids, pinned = false) {
const [channel] = this._getRecords('mail.channel', [['id', 'in', ids]]);
const [memberOfCurrentUser] = this._getRecords('mail.channel.partner', [['channel_id', '=', channel.id], ['partner_id', '=', this.currentPartnerId], ['is_pinned', '!=', pinned]]);
if (memberOfCurrentUser) {
this._mockWrite('mail.channel.partner', [
@@ -10,7 +10,7 @@ class MailChannel(models.Model):
livechat_visitor_id = fields.Many2one('website.visitor', string='Visitor')
def _execute_channel_pin(self, pinned=False):
def channel_pin(self, pinned=False):
""" Override to clean an empty livechat channel.
This is typically called when the operator send a chat request to a website.visitor
but don't speak to him and closes the chatter.
@@ -18,7 +18,7 @@ class MailChannel(models.Model):
If active empty livechat channel,
delete mail_channel as not useful to keep empty chat
"""
super(MailChannel, self)._execute_channel_pin(pinned)
super().channel_pin(pinned=pinned)
if self.livechat_active and not self.message_ids:
self.unlink()