553b0c20faaa16045c379285a6e622ea7b87816f
[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 _0x2638=['then','createdAt','toLowerCase','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','request-promise','path','rimraf','../../config/environment','define','FaxMessage','fti_fax_messages','body','FULLTEXT','get','direction','out','secret','isNil','UserId','FaxInteractionId'];(function(_0xc47422,_0x4d1274){var _0x4fe049=function(_0x4bd1c3){while(--_0x4bd1c3){_0xc47422['push'](_0xc47422['shift']());}};_0x4fe049(++_0x4d1274);}(_0x2638,0x1f4));var _0x8263=function(_0x18b34d,_0x1bd683){_0x18b34d=_0x18b34d-0x0;var _0x4ec0f3=_0x2638[_0x18b34d];return _0x4ec0f3;};'use strict';var _=require(_0x8263('0x0'));var util=require(_0x8263('0x1'));var logger=require('../../config/logger')(_0x8263('0x2'));var moment=require(_0x8263('0x3'));var BPromise=require('bluebird');var rp=require(_0x8263('0x4'));var fs=require('fs');var path=require(_0x8263('0x5'));var rimraf=require(_0x8263('0x6'));var config=require(_0x8263('0x7'));var attributes=require('./faxMessage.attributes');module['exports']=function(_0x358918,_0x1f983e){return _0x358918[_0x8263('0x8')](_0x8263('0x9'),attributes,{'tableName':'fax_messages','paranoid':![],'indexes':[{'name':_0x8263('0xa'),'fields':[_0x8263('0xb')],'type':_0x8263('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x247546,_0x460b76,_0x13cf8d){var _0x301f51=_0x358918['models'];var _0x5746eb=_0x247546[_0x8263('0xd')]({'plain':!![]});if(_0x5746eb[_0x8263('0xe')]['toLowerCase']()==='in'||_0x5746eb[_0x8263('0xe')]['toLowerCase']()===_0x8263('0xf')&&!_0x5746eb[_0x8263('0x10')]&&!_[_0x8263('0x11')](_0x5746eb[_0x8263('0x12')])){_0x301f51['FaxInteraction']['findOne']({'where':{'id':_0x5746eb[_0x8263('0x13')]}})[_0x8263('0x14')](function(_0x2772d5){if(_0x2772d5){_0x2772d5['update']({'lastMsgAt':_0x5746eb[_0x8263('0x15')],'lastMsgDirection':_0x5746eb[_0x8263('0xe')][_0x8263('0x16')]()});}})['catch'](function(_0x10fef6){console[_0x8263('0x17')](_0x10fef6);});}_0x13cf8d();}},'charset':_0x8263('0x18'),'collate':_0x8263('0x19')});};