760419b7234a3ed5fc35eefd4423732fe8196d6f
[motion2.git] / server / api / mailInteraction / mailInteraction.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x79b5=['substatus','format','YYYY-MM-DD\x20HH:mm:ss','closed','closedAt','changed','MailMessage','then','catch','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','request-promise','path','rimraf','../../config/environment','./mailInteraction.attributes','exports','define','MailInteraction','mail_interactions','subject','FULLTEXT'];(function(_0x3f4bcb,_0x30ab38){var _0x31ff0c=function(_0x1cc868){while(--_0x1cc868){_0x3f4bcb['push'](_0x3f4bcb['shift']());}};_0x31ff0c(++_0x30ab38);}(_0x79b5,0xdb));var _0x579b=function(_0x5a4b2d,_0x3f21d5){_0x5a4b2d=_0x5a4b2d-0x0;var _0xbb7498=_0x79b5[_0x5a4b2d];return _0xbb7498;};'use strict';var _=require(_0x579b('0x0'));var util=require(_0x579b('0x1'));var logger=require('../../config/logger')(_0x579b('0x2'));var moment=require(_0x579b('0x3'));var BPromise=require('bluebird');var rp=require(_0x579b('0x4'));var fs=require('fs');var path=require(_0x579b('0x5'));var rimraf=require(_0x579b('0x6'));var config=require(_0x579b('0x7'));var attributes=require(_0x579b('0x8'));module[_0x579b('0x9')]=function(_0x2f5abf,_0x594fd6){return _0x2f5abf[_0x579b('0xa')](_0x579b('0xb'),attributes,{'tableName':_0x579b('0xc'),'paranoid':![],'indexes':[{'name':'fti_mail_interactions','fields':[_0x579b('0xd'),'to'],'type':_0x579b('0xe')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x4607dc,_0x5dafc7,_0x1c47d0){if(_0x4607dc[_0x579b('0xf')]){_0x4607dc['substatusAt']=moment()[_0x579b('0x10')](_0x579b('0x11'));}if(_0x4607dc[_0x579b('0x12')]){_0x4607dc[_0x579b('0x13')]=moment()[_0x579b('0x10')](_0x579b('0x11'));}_0x1c47d0(null,_0x5dafc7);},'beforeUpdate':function(_0xf5e9d2,_0x1d99ad,_0x3ef555){if(_0xf5e9d2[_0x579b('0x14')]('substatus')){_0xf5e9d2['substatusAt']=_0xf5e9d2[_0x579b('0xf')]?moment()[_0x579b('0x10')]('YYYY-MM-DD\x20HH:mm:ss'):null;}if(_0xf5e9d2[_0x579b('0x14')](_0x579b('0x12'))){_0xf5e9d2[_0x579b('0x13')]=moment()[_0x579b('0x10')]('YYYY-MM-DD\x20HH:mm:ss');_0xf5e9d2[_0x579b('0xf')]=null;_0xf5e9d2['substatusAt']=null;}_0x3ef555(null,_0xf5e9d2);},'afterUpdate':function(_0x2174f1,_0x36f352,_0x5ee5c8){var _0x3b7bc1=_0x2f5abf['models'];var _0x375f4d=_0x2174f1['get']({'plain':!![]});if(_0x375f4d[_0x579b('0x12')]){return _0x3b7bc1[_0x579b('0x15')]['update']({'read':!![]},{'where':{'MailInteractionId':_0x375f4d['id']}})[_0x579b('0x16')](function(){_0x5ee5c8();})[_0x579b('0x17')](function(_0x3b9647){_0x5ee5c8(_0x3b9647);});}else{_0x5ee5c8();}}},'charset':_0x579b('0x18'),'collate':_0x579b('0x19')});};