summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/services
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-07-26 15:12:29 +0200
committerChristophe Simonis <chs@odoo.com>2019-07-26 15:12:29 +0200
commitbfd34e14b1be97465e135d85c76b9e626a219e7a (patch)
tree8de54ec8f504158e965ab92e21658cab539024ee /addons/mail/static/src/js/services
parent26b5b446b3dab3d66b7db054ca77e7b1a811c28a (diff)
parent40e8b67179f212551a176d72b3851671febc1fba (diff)
[MERGE] forward port branch saas-12.3 up to 40e8b67179f
Diffstat (limited to 'addons/mail/static/src/js/services')
-rw-r--r--addons/mail/static/src/js/services/mail_document_thread_manager.js17
-rw-r--r--addons/mail/static/src/js/services/mail_notification_manager.js3
-rw-r--r--addons/mail/static/src/js/services/mail_status_manager.js32
-rw-r--r--addons/mail/static/src/js/services/mail_window_manager.js13
4 files changed, 53 insertions, 12 deletions
diff --git a/addons/mail/static/src/js/services/mail_document_thread_manager.js b/addons/mail/static/src/js/services/mail_document_thread_manager.js
index f1d9eefb44a..acf06461a04 100644
--- a/addons/mail/static/src/js/services/mail_document_thread_manager.js
+++ b/addons/mail/static/src/js/services/mail_document_thread_manager.js
@@ -48,23 +48,16 @@ MailManager.include({
*
* @override
* @param {Object} data
- * @param {Array} [data.author_id] [int, string] where int is server ID of
- * the author, and string is the name of the author.
* @param {integer} data.id server ID of the message
- * @param {string} [data.model] the model name of the document that this
- * message is related to.
- * @param {integer} [data.res_id] the ID of the document that this message
- * is related to.
- *
+ * @param {Object} [options]
+ * @param {boolean} [options.postedFromDocumentThread=false]
*/
- addMessage: function (data) {
+ addMessage: function (data, options) {
var message = this.getMessage(data.id);
if (
!message &&
- data.res_id &&
- data.model &&
- data.author_id &&
- data.author_id[0] === session.partner_id
+ options &&
+ options.postedFromDocumentThread
) {
var key = this.DOCUMENT_THREAD_MESSAGE_KEY;
this.call('local_storage', 'setItem', key, data);
diff --git a/addons/mail/static/src/js/services/mail_notification_manager.js b/addons/mail/static/src/js/services/mail_notification_manager.js
index caf0c3c4e12..c22276867b1 100644
--- a/addons/mail/static/src/js/services/mail_notification_manager.js
+++ b/addons/mail/static/src/js/services/mail_notification_manager.js
@@ -417,6 +417,9 @@ MailManager.include({
this._handlePartnerUserConnectionNotification(data);
} else if (data.info === 'channel_seen') {
this._handlePartnerChannnelSeenNotification(data);
+ } else if (data.type === 'simple_notification') {
+ var title = _.escape(data.title), message = _.escape(data.message);
+ data.warning ? this.do_warn(title, message, data.sticky) : this.do_notify(title, message, data.sticky);
} else {
this._handlePartnerChannelNotification(data);
}
diff --git a/addons/mail/static/src/js/services/mail_status_manager.js b/addons/mail/static/src/js/services/mail_status_manager.js
index 7891461c9af..a40299a02d5 100644
--- a/addons/mail/static/src/js/services/mail_status_manager.js
+++ b/addons/mail/static/src/js/services/mail_status_manager.js
@@ -54,13 +54,45 @@ MailManager.include({
updateImStatus: function (statusList) {
var updatedIDs = [];
var self = this;
+ var dmChat;
+ var toUpdateOutOfOfficeChatIDs = [];
_.each(statusList, function (status) {
if (self._imStatus[status.id] === status.im_status) {
return;
}
+ if (
+ status.im_status.indexOf('leave') !== -1 ||
+ (
+ self._imStatus[status.id] &&
+ self._imStatus[status.id].indexOf('leave') !== -1
+ )
+ ) {
+ dmChat = self.getDMChatFromPartnerID(status.id);
+ if (dmChat) {
+ toUpdateOutOfOfficeChatIDs.push(dmChat.getID());
+ }
+ }
updatedIDs.push(status.id);
self._imStatus[status.id] = status.im_status;
});
+ if (!_.isEmpty(toUpdateOutOfOfficeChatIDs)) {
+ this._rpc({
+ model: 'mail.channel',
+ method: 'channel_info',
+ args: [toUpdateOutOfOfficeChatIDs],
+ }).then(function (channelsInfo) {
+ _.each(channelsInfo, function (channelInfo) {
+ dmChat = self.getChannel(channelInfo.id);
+ if (!dmChat) {
+ return;
+ }
+ dmChat.updateOutOfOfficeInfo({
+ outOfOfficeMessage: channelInfo.direct_partner[0].out_of_office_message,
+ outOfOfficeDateEnd: channelInfo.direct_partner[0].out_of_office_date_end,
+ });
+ });
+ });
+ }
if (! _.isEmpty(updatedIDs)) {
this._mailBus.trigger('updated_im_status', updatedIDs); // useful for thread window header
this._renderImStatus(updatedIDs);
diff --git a/addons/mail/static/src/js/services/mail_window_manager.js b/addons/mail/static/src/js/services/mail_window_manager.js
index 6214fc8b5b7..81f0ef7e97c 100644
--- a/addons/mail/static/src/js/services/mail_window_manager.js
+++ b/addons/mail/static/src/js/services/mail_window_manager.js
@@ -344,6 +344,7 @@ MailManager.include({
.on('is_thread_bottom_visible', this, this._onIsThreadBottomVisible)
.on('unsubscribe_from_channel', this, this._onUnsubscribeFromChannel)
.on('updated_im_status', this, this._onUpdatedImStatus)
+ .on('updated_out_of_office', this, this._onUpdatedOutOfOffice)
.on('update_thread_unread_counter', this, this._onUpdateThreadUnreadCounter);
core.bus.on('resize', this, _.debounce(this._repositionThreadWindows.bind(this), 100));
@@ -701,6 +702,18 @@ MailManager.include({
});
},
/**
+ * @private
+ * @param {Object} data
+ * @param {integer} data.threadID
+ */
+ _onUpdatedOutOfOffice: function (data) {
+ var threadWindow = this._getThreadWindow(data.threadID);
+ if (!threadWindow) {
+ return;
+ }
+ threadWindow.renderOutOfOffice();
+ },
+ /**
* Called when a thread has its unread counter that has changed.
* The unread counter on the thread windows should be updated.
*