summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/models/threads/dm_chat.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/js/models/threads/dm_chat.js')
-rw-r--r--addons/mail/static/src/js/models/threads/dm_chat.js49
1 files changed, 45 insertions, 4 deletions
diff --git a/addons/mail/static/src/js/models/threads/dm_chat.js b/addons/mail/static/src/js/models/threads/dm_chat.js
index 5e69dbeff8c..fb524515193 100644
--- a/addons/mail/static/src/js/models/threads/dm_chat.js
+++ b/addons/mail/static/src/js/models/threads/dm_chat.js
@@ -3,6 +3,10 @@ odoo.define('mail.model.DMChat', function (require) {
var TwoUserChannel = require('mail.model.TwoUserChannel');
+var core = require('web.core');
+
+var _t = core._t;
+
/**
* Any piece of code in JS that make use of DMs must ideally interact with
* such objects, instead of direct data from the server.
@@ -18,6 +22,8 @@ var DMChat = TwoUserChannel.extend({
* @param {integer} params.data.direct_partner[0].id
* @param {string} params.data.direct_partner[0].im_status
* @param {string} params.data.direct_partner[0].name
+ * @param {string} [params.data.direct_partner[0].out_of_office_message]
+ * @param {string} [params.data.direct_partner[0].out_of_office_date_end]
*/
init: function (params) {
this._super.apply(this, arguments);
@@ -26,8 +32,14 @@ var DMChat = TwoUserChannel.extend({
this._directPartnerID = data.direct_partner[0].id;
this._name = data.custom_channel_name || data.direct_partner[0].name;
- this._status = data.direct_partner[0].im_status;
+ this._outOfOfficeMessage = data.direct_partner[0].out_of_office_message;
+ this._outOfOfficeDateEnd = data.direct_partner[0].out_of_office_date_end;
this._type = 'dm_chat';
+
+ this.call('mail_service', 'updateImStatus', [{
+ id: this._directPartnerID,
+ im_status: data.direct_partner[0].im_status
+ }]);
},
//--------------------------------------------------------------------------
@@ -45,6 +57,34 @@ var DMChat = TwoUserChannel.extend({
return this._directPartnerID;
},
/**
+ * Get the out of office info
+ *
+ * @override {mail.model.AbstractThread}
+ * @returns {string|undefined}
+ */
+ getOutOfOfficeInfo: function () {
+ if (!this._outOfOfficeDateEnd) {
+ return undefined;
+ }
+ var currentDate = new Date();
+ var date = new Date(this._outOfOfficeDateEnd);
+ var options = { day: 'numeric', month: 'short' };
+ if (currentDate.getFullYear() !== date.getFullYear()) {
+ options.year = 'numeric';
+ }
+ var formattedDate = date.toLocaleDateString(window.navigator.language, options);
+ return _.str.sprintf(_t("Out of office until %s"), formattedDate);
+ },
+ /**
+ * Get the out of office message of the thread
+ *
+ * @override {mail.model.AbstractThread}
+ * @returns {string}
+ */
+ getOutOfOfficeMessage: function () {
+ return this._outOfOfficeMessage;
+ },
+ /**
* @override
*/
getPreview: function () {
@@ -53,10 +93,11 @@ var DMChat = TwoUserChannel.extend({
return result;
},
/**
- * @param {string} newStatus
+ * @override
+ * @return {string}
*/
- setStatus: function (newStatus) {
- this._status = newStatus;
+ getStatus: function () {
+ return this.call('mail_service', 'getImStatus', { partnerID: this._directPartnerID });
},
});