Built motion from commit 953226e6.|2.6.32
[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 _0x3460=['body','FULLTEXT','models','get','direction','toLowerCase','secret','UserId','FaxInteractionId','createdAt','catch','error','utf8mb4','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','./faxMessage.attributes','exports','define','FaxMessage','fax_messages'];(function(_0x93dc77,_0x1857e9){var _0xf1250e=function(_0x5da45a){while(--_0x5da45a){_0x93dc77['push'](_0x93dc77['shift']());}};_0xf1250e(++_0x1857e9);}(_0x3460,0x15f));var _0x0346=function(_0x1db23c,_0x52a597){_0x1db23c=_0x1db23c-0x0;var _0x22bab9=_0x3460[_0x1db23c];return _0x22bab9;};'use strict';var _=require(_0x0346('0x0'));var util=require(_0x0346('0x1'));var logger=require(_0x0346('0x2'))(_0x0346('0x3'));var moment=require(_0x0346('0x4'));var BPromise=require(_0x0346('0x5'));var rp=require(_0x0346('0x6'));var fs=require('fs');var path=require(_0x0346('0x7'));var rimraf=require('rimraf');var config=require('../../config/environment');var attributes=require(_0x0346('0x8'));module[_0x0346('0x9')]=function(_0xa1e531,_0x2f843f){return _0xa1e531[_0x0346('0xa')](_0x0346('0xb'),attributes,{'tableName':_0x0346('0xc'),'paranoid':![],'indexes':[{'name':'fti_fax_messages','fields':[_0x0346('0xd')],'type':_0x0346('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5d2f88,_0x104989,_0x4405f7){var _0x531535=_0xa1e531[_0x0346('0xf')];var _0xb5e730=_0x5d2f88[_0x0346('0x10')]({'plain':!![]});if(_0xb5e730[_0x0346('0x11')][_0x0346('0x12')]()==='in'||_0xb5e730[_0x0346('0x11')][_0x0346('0x12')]()==='out'&&!_0xb5e730[_0x0346('0x13')]&&!_['isNil'](_0xb5e730[_0x0346('0x14')])){_0x531535['FaxInteraction']['findOne']({'where':{'id':_0xb5e730[_0x0346('0x15')]}})['then'](function(_0xcfc18f){if(_0xcfc18f){_0xcfc18f['update']({'lastMsgAt':_0xb5e730[_0x0346('0x16')],'lastMsgDirection':_0xb5e730[_0x0346('0x11')][_0x0346('0x12')]()});}})[_0x0346('0x17')](function(_0x101762){console[_0x0346('0x18')](_0x101762);});}_0x4405f7();}},'charset':_0x0346('0x19'),'collate':'utf8mb4_unicode_ci'});};