Built motion from commit 47436d59.|2.6.7
[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 _0x2f2a=['changed','substatus','models','get','MailMessage','then','catch','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','bluebird','path','rimraf','../../config/environment','./mailInteraction.attributes','exports','define','mail_interactions','fti_mail_interactions','FULLTEXT','substatusAt','YYYY-MM-DD\x20HH:mm:ss','closed','closedAt','format'];(function(_0xcd7827,_0x5effe2){var _0x432f21=function(_0x3ffdc6){while(--_0x3ffdc6){_0xcd7827['push'](_0xcd7827['shift']());}};_0x432f21(++_0x5effe2);}(_0x2f2a,0x159));var _0xa2f2=function(_0x5b7788,_0x309ae5){_0x5b7788=_0x5b7788-0x0;var _0x573871=_0x2f2a[_0x5b7788];return _0x573871;};'use strict';var _=require(_0xa2f2('0x0'));var util=require(_0xa2f2('0x1'));var logger=require(_0xa2f2('0x2'))(_0xa2f2('0x3'));var moment=require('moment');var BPromise=require(_0xa2f2('0x4'));var rp=require('request-promise');var fs=require('fs');var path=require(_0xa2f2('0x5'));var rimraf=require(_0xa2f2('0x6'));var config=require(_0xa2f2('0x7'));var attributes=require(_0xa2f2('0x8'));module[_0xa2f2('0x9')]=function(_0x165454,_0xd047e){return _0x165454[_0xa2f2('0xa')]('MailInteraction',attributes,{'tableName':_0xa2f2('0xb'),'paranoid':![],'indexes':[{'name':_0xa2f2('0xc'),'fields':['subject','to'],'type':_0xa2f2('0xd')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x5a4ea8,_0x476a79,_0xb8a7f1){if(_0x5a4ea8['substatus']){_0x5a4ea8[_0xa2f2('0xe')]=moment()['format'](_0xa2f2('0xf'));}if(_0x5a4ea8[_0xa2f2('0x10')]){_0x5a4ea8[_0xa2f2('0x11')]=moment()[_0xa2f2('0x12')]('YYYY-MM-DD\x20HH:mm:ss');}_0xb8a7f1(null,_0x476a79);},'beforeUpdate':function(_0x1b587b,_0xbb13ea,_0x509939){if(_0x1b587b[_0xa2f2('0x13')](_0xa2f2('0x14'))){_0x1b587b[_0xa2f2('0xe')]=_0x1b587b[_0xa2f2('0x14')]?moment()[_0xa2f2('0x12')]('YYYY-MM-DD\x20HH:mm:ss'):null;}if(_0x1b587b[_0xa2f2('0x13')]('closed')){_0x1b587b[_0xa2f2('0x11')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x1b587b[_0xa2f2('0x14')]=null;_0x1b587b[_0xa2f2('0xe')]=null;}_0x509939(null,_0x1b587b);},'afterUpdate':function(_0x107e1c,_0x5845a9,_0x1d9a61){var _0x4b3bd9=_0x165454[_0xa2f2('0x15')];var _0x2b1e52=_0x107e1c[_0xa2f2('0x16')]({'plain':!![]});if(_0x2b1e52[_0xa2f2('0x10')]){return _0x4b3bd9[_0xa2f2('0x17')]['update']({'read':!![]},{'where':{'MailInteractionId':_0x2b1e52['id']}})[_0xa2f2('0x18')](function(){_0x1d9a61();})[_0xa2f2('0x19')](function(_0x56c751){_0x1d9a61(_0x56c751);});}else{_0x1d9a61();}}},'charset':_0xa2f2('0x1a'),'collate':_0xa2f2('0x1b')});};