[IMP] mail: turn 'Message/avatarUrl' into field
Task-2793280 closes odoo/odoo#86446 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -87,27 +87,6 @@ export class Message extends Component {
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
get avatar() {
|
||||
if (this.messageView.message.author && (!this.messageView.message.originThread || this.messageView.message.originThread.model !== 'mail.channel')) {
|
||||
// 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
|
||||
return this.messageView.message.author.avatarUrl;
|
||||
} else if (this.messageView.message.author && this.messageView.message.originThread && this.messageView.message.originThread.model === 'mail.channel') {
|
||||
return `/mail/channel/${this.messageView.message.originThread.id}/partner/${this.messageView.message.author.id}/avatar_128`;
|
||||
} else if (this.messageView.message.guestAuthor && (!this.messageView.message.originThread || this.messageView.message.originThread.model !== 'mail.channel')) {
|
||||
return this.messageView.message.guestAuthor.avatarUrl;
|
||||
} else if (this.messageView.message.guestAuthor && this.messageView.message.originThread && this.messageView.message.originThread.model === 'mail.channel') {
|
||||
return `/mail/channel/${this.messageView.message.originThread.id}/guest/${this.messageView.message.guestAuthor.id}/avatar_128?unique=${this.messageView.message.guestAuthor.name}`;
|
||||
} else if (this.messageView.message.message_type === 'email') {
|
||||
return '/mail/static/src/img/email_icon.png';
|
||||
}
|
||||
return '/mail/static/src/img/smiley/avatar.jpg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date time of the message at current user locale time.
|
||||
*
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="o_Message_sidebar" t-att-class="{ 'o-message-squashed align-items-start': messageView.isSquashed }">
|
||||
<t t-if="!messageView.isSquashed">
|
||||
<div class="o_Message_authorAvatarContainer o_Message_sidebarItem">
|
||||
<img class="o_Message_authorAvatar rounded-circle" t-att-class="{ o_Message_authorRedirect: hasAuthorOpenChat, o_redirect: hasAuthorOpenChat }" t-att-src="avatar" t-on-click="_onClickAuthorAvatar" t-att-title="hasAuthorOpenChat ? OPEN_CHAT : ''" alt="Avatar"/>
|
||||
<img class="o_Message_authorAvatar rounded-circle" t-att-class="{ o_Message_authorRedirect: hasAuthorOpenChat, o_redirect: hasAuthorOpenChat }" t-att-src="messageView.message.avatarUrl" t-on-click="_onClickAuthorAvatar" t-att-title="hasAuthorOpenChat ? OPEN_CHAT : ''" alt="Avatar"/>
|
||||
<t t-if="messageView.message.author and messageView.message.author.im_status">
|
||||
<PartnerImStatusIcon
|
||||
className="'o_Message_partnerImStatusIcon'"
|
||||
|
||||
@@ -304,6 +304,27 @@ registerModel({
|
||||
}
|
||||
return this.env._t("Anonymous");
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @returns {string}
|
||||
*/
|
||||
_computeAvatarUrl() {
|
||||
if (this.author && (!this.originThread || this.originThread.model !== 'mail.channel')) {
|
||||
// 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
|
||||
return this.author.avatarUrl;
|
||||
} else if (this.author && this.originThread && this.originThread.model === 'mail.channel') {
|
||||
return `/mail/channel/${this.originThread.id}/partner/${this.author.id}/avatar_128`;
|
||||
} else if (this.guestAuthor && (!this.originThread || this.originThread.model !== 'mail.channel')) {
|
||||
return this.guestAuthor.avatarUrl;
|
||||
} else if (this.guestAuthor && this.originThread && this.originThread.model === 'mail.channel') {
|
||||
return `/mail/channel/${this.originThread.id}/guest/${this.guestAuthor.id}/avatar_128?unique=${this.guestAuthor.name}`;
|
||||
} else if (this.message_type === 'email') {
|
||||
return '/mail/static/src/img/email_icon.png';
|
||||
}
|
||||
return '/mail/static/src/img/smiley/avatar.jpg';
|
||||
},
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
@@ -562,6 +583,9 @@ registerModel({
|
||||
inverse: 'messages',
|
||||
}),
|
||||
author: one('Partner'),
|
||||
avatarUrl: attr({
|
||||
compute: '_computeAvatarUrl'
|
||||
}),
|
||||
/**
|
||||
* This value is meant to be returned by the server
|
||||
* (and has been sanitized before stored into db).
|
||||
|
||||
Reference in New Issue
Block a user