a4a4876f2eb56a5d005fa31995bd745fd0c26125
[motion2.git] / server / api / faxMessage / faxMessage.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 _0x432f=['path','rimraf','../../config/environment','./faxMessage.attributes','exports','FaxMessage','fax_messages','fti_fax_messages','body','FULLTEXT','models','get','toLowerCase','direction','out','secret','isNil','UserId','FaxInteraction','findOne','then','createdAt','error','utf8mb4_unicode_ci','lodash','util','api','moment','bluebird','request-promise'];(function(_0x478eb4,_0x5e0ac4){var _0x2db771=function(_0x1afb2b){while(--_0x1afb2b){_0x478eb4['push'](_0x478eb4['shift']());}};_0x2db771(++_0x5e0ac4);}(_0x432f,0x1da));var _0xf432=function(_0xc0a3d3,_0x2c8d00){_0xc0a3d3=_0xc0a3d3-0x0;var _0x3386e8=_0x432f[_0xc0a3d3];return _0x3386e8;};'use strict';var _=require(_0xf432('0x0'));var util=require(_0xf432('0x1'));var logger=require('../../config/logger')(_0xf432('0x2'));var moment=require(_0xf432('0x3'));var BPromise=require(_0xf432('0x4'));var rp=require(_0xf432('0x5'));var fs=require('fs');var path=require(_0xf432('0x6'));var rimraf=require(_0xf432('0x7'));var config=require(_0xf432('0x8'));var attributes=require(_0xf432('0x9'));module[_0xf432('0xa')]=function(_0x19974c,_0x17195b){return _0x19974c['define'](_0xf432('0xb'),attributes,{'tableName':_0xf432('0xc'),'paranoid':![],'indexes':[{'name':_0xf432('0xd'),'fields':[_0xf432('0xe')],'type':_0xf432('0xf')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x52c2a4,_0x407b56,_0x4022a3){var _0x4f4c78=_0x19974c[_0xf432('0x10')];var _0x528b15=_0x52c2a4[_0xf432('0x11')]({'plain':!![]});if(_0x528b15['direction'][_0xf432('0x12')]()==='in'||_0x528b15[_0xf432('0x13')]['toLowerCase']()===_0xf432('0x14')&&!_0x528b15[_0xf432('0x15')]&&!_[_0xf432('0x16')](_0x528b15[_0xf432('0x17')])){_0x4f4c78[_0xf432('0x18')][_0xf432('0x19')]({'where':{'id':_0x528b15['FaxInteractionId']}})[_0xf432('0x1a')](function(_0x40a03c){if(_0x40a03c){_0x40a03c['update']({'lastMsgAt':_0x528b15[_0xf432('0x1b')],'lastMsgDirection':_0x528b15['direction'][_0xf432('0x12')]()});}})['catch'](function(_0x2dc873){console[_0xf432('0x1c')](_0x2dc873);});}_0x4022a3();}},'charset':'utf8mb4','collate':_0xf432('0x1d')});};