Built motion from commit (unavailable).|2.5.27
[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 _0x61be=['substatusAt','format','YYYY-MM-DD\x20HH:mm:ss','closedAt','changed','closed','models','MailMessage','update','catch','utf8mb4','lodash','util','../../config/logger','bluebird','rimraf','../../config/environment','./mailInteraction.attributes','exports','define','mail_interactions','FULLTEXT','substatus'];(function(_0x166cc7,_0x486d0c){var _0x196799=function(_0x598af5){while(--_0x598af5){_0x166cc7['push'](_0x166cc7['shift']());}};_0x196799(++_0x486d0c);}(_0x61be,0x1d7));var _0xe61b=function(_0x3a1d35,_0xb3ce46){_0x3a1d35=_0x3a1d35-0x0;var _0x4a585c=_0x61be[_0x3a1d35];return _0x4a585c;};'use strict';var _=require(_0xe61b('0x0'));var util=require(_0xe61b('0x1'));var logger=require(_0xe61b('0x2'))('api');var moment=require('moment');var BPromise=require(_0xe61b('0x3'));var rp=require('request-promise');var fs=require('fs');var path=require('path');var rimraf=require(_0xe61b('0x4'));var config=require(_0xe61b('0x5'));var attributes=require(_0xe61b('0x6'));module[_0xe61b('0x7')]=function(_0x5850c7,_0x4d218f){return _0x5850c7[_0xe61b('0x8')]('MailInteraction',attributes,{'tableName':_0xe61b('0x9'),'paranoid':![],'indexes':[{'name':'fti_mail_interactions','fields':['subject','to'],'type':_0xe61b('0xa')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x1dd61f,_0x23b7c1,_0x26314f){if(_0x1dd61f[_0xe61b('0xb')]){_0x1dd61f[_0xe61b('0xc')]=moment()[_0xe61b('0xd')](_0xe61b('0xe'));}if(_0x1dd61f['closed']){_0x1dd61f[_0xe61b('0xf')]=moment()[_0xe61b('0xd')](_0xe61b('0xe'));}_0x26314f(null,_0x23b7c1);},'beforeUpdate':function(_0x34dad9,_0x41dc2b,_0xc140c7){if(_0x34dad9[_0xe61b('0x10')]('substatus')){_0x34dad9['substatusAt']=_0x34dad9[_0xe61b('0xb')]?moment()[_0xe61b('0xd')](_0xe61b('0xe')):null;}if(_0x34dad9['changed'](_0xe61b('0x11'))){_0x34dad9[_0xe61b('0xf')]=moment()[_0xe61b('0xd')](_0xe61b('0xe'));_0x34dad9['substatus']=null;_0x34dad9[_0xe61b('0xc')]=null;}_0xc140c7(null,_0x34dad9);},'afterUpdate':function(_0xde5e28,_0x3a4a69,_0x16be3c){var _0x3123de=_0x5850c7[_0xe61b('0x12')];var _0x4cd42b=_0xde5e28['get']({'plain':!![]});if(_0x4cd42b[_0xe61b('0x11')]){return _0x3123de[_0xe61b('0x13')][_0xe61b('0x14')]({'read':!![]},{'where':{'MailInteractionId':_0x4cd42b['id']}})['then'](function(){_0x16be3c();})[_0xe61b('0x15')](function(_0x158bfa){_0x16be3c(_0x158bfa);});}else{_0x16be3c();}}},'charset':_0xe61b('0x16'),'collate':'utf8mb4_unicode_ci'});};