[IMP] mail: move odoobot avatar logic in partner model
task-2348684 closes odoo/odoo#58969 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
committed by
Alexandre Kühn
parent
ad2f0eff5e
commit
78cdf8089b
@@ -131,12 +131,7 @@ class Message extends Component {
|
||||
* @returns {string}
|
||||
*/
|
||||
get avatar() {
|
||||
if (
|
||||
this.message.author &&
|
||||
this.message.author === this.env.messaging.partnerRoot
|
||||
) {
|
||||
return '/mail/static/src/img/odoobot.png';
|
||||
} else if (this.message.author) {
|
||||
if (this.message.author) {
|
||||
// TODO FIXME for public user this might not be accessible. task-2223236
|
||||
// we should probably use the correspondig attachment id + access token
|
||||
// or create a dedicated route to get message image, checking the access right of the message
|
||||
|
||||
@@ -195,6 +195,9 @@ function factory(dependencies) {
|
||||
* @returns {string}
|
||||
*/
|
||||
_computeAvatarUrl() {
|
||||
if (this === this.env.messaging.partnerRoot) {
|
||||
return '/mail/static/src/img/odoobot.png';
|
||||
}
|
||||
return `/web/image/res.partner/${this.id}/image_128`;
|
||||
}
|
||||
|
||||
@@ -260,6 +263,14 @@ function factory(dependencies) {
|
||||
return this.display_name || this.user && this.user.display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {mail.messaging}
|
||||
*/
|
||||
_computeMessaging() {
|
||||
return [['link', this.env.messaging]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {string|undefined}
|
||||
@@ -278,6 +289,7 @@ function factory(dependencies) {
|
||||
compute: '_computeAvatarUrl',
|
||||
dependencies: [
|
||||
'id',
|
||||
'messagingPartnerRoot',
|
||||
],
|
||||
}),
|
||||
correspondentThreads: one2many('mail.thread', {
|
||||
@@ -311,6 +323,12 @@ function factory(dependencies) {
|
||||
messagesAsAuthor: one2many('mail.message', {
|
||||
inverse: 'author',
|
||||
}),
|
||||
messaging: many2one('mail.messaging', {
|
||||
compute: '_computeMessaging',
|
||||
}),
|
||||
messagingPartnerRoot: many2one('mail.partner', {
|
||||
related: 'messaging.partnerRoot',
|
||||
}),
|
||||
model: attr({
|
||||
default: 'res.partner',
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user