Built motion from commit 25580385.|2.6.2
[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 _0x5aea=['isNil','findOne','FaxInteractionId','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','moment','bluebird','request-promise','path','rimraf','../../config/environment','./faxMessage.attributes','define','FaxMessage','fax_messages','fti_fax_messages','body','FULLTEXT','get','direction','toLowerCase','out'];(function(_0x37ff2a,_0x260ba4){var _0x54b493=function(_0x274d68){while(--_0x274d68){_0x37ff2a['push'](_0x37ff2a['shift']());}};_0x54b493(++_0x260ba4);}(_0x5aea,0xaa));var _0xa5ae=function(_0x2c5352,_0xc84c02){_0x2c5352=_0x2c5352-0x0;var _0x2c4ef1=_0x5aea[_0x2c5352];return _0x2c4ef1;};'use strict';var _=require(_0xa5ae('0x0'));var util=require('util');var logger=require(_0xa5ae('0x1'))('api');var moment=require(_0xa5ae('0x2'));var BPromise=require(_0xa5ae('0x3'));var rp=require(_0xa5ae('0x4'));var fs=require('fs');var path=require(_0xa5ae('0x5'));var rimraf=require(_0xa5ae('0x6'));var config=require(_0xa5ae('0x7'));var attributes=require(_0xa5ae('0x8'));module['exports']=function(_0x1eb892,_0x546910){return _0x1eb892[_0xa5ae('0x9')](_0xa5ae('0xa'),attributes,{'tableName':_0xa5ae('0xb'),'paranoid':![],'indexes':[{'name':_0xa5ae('0xc'),'fields':[_0xa5ae('0xd')],'type':_0xa5ae('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2862b6,_0x2d0505,_0x1514ec){var _0x2819ac=_0x1eb892['models'];var _0x5e1ca7=_0x2862b6[_0xa5ae('0xf')]({'plain':!![]});if(_0x5e1ca7[_0xa5ae('0x10')][_0xa5ae('0x11')]()==='in'||_0x5e1ca7['direction']['toLowerCase']()===_0xa5ae('0x12')&&!_0x5e1ca7['secret']&&!_[_0xa5ae('0x13')](_0x5e1ca7['UserId'])){_0x2819ac['FaxInteraction'][_0xa5ae('0x14')]({'where':{'id':_0x5e1ca7[_0xa5ae('0x15')]}})['then'](function(_0x563c8c){if(_0x563c8c){_0x563c8c['update']({'lastMsgAt':_0x5e1ca7[_0xa5ae('0x16')],'lastMsgDirection':_0x5e1ca7[_0xa5ae('0x10')][_0xa5ae('0x11')]()});}})[_0xa5ae('0x17')](function(_0x35e4ce){console[_0xa5ae('0x18')](_0x35e4ce);});}_0x1514ec();}},'charset':_0xa5ae('0x19'),'collate':_0xa5ae('0x1a')});};