62f3235d717b6efdd75eb405e00195c9c3c7863c
[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 _0x9761=['api','moment','request-promise','path','rimraf','../../config/environment','./faxMessage.attributes','exports','FaxMessage','fax_messages','fti_fax_messages','body','FULLTEXT','toLowerCase','direction','out','secret','isNil','UserId','FaxInteraction','findOne','FaxInteractionId','then','update','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger'];(function(_0x46698a,_0x8de1e4){var _0x356db0=function(_0x19e83c){while(--_0x19e83c){_0x46698a['push'](_0x46698a['shift']());}};_0x356db0(++_0x8de1e4);}(_0x9761,0x1de));var _0x1976=function(_0x57a724,_0x5988a2){_0x57a724=_0x57a724-0x0;var _0x50c617=_0x9761[_0x57a724];return _0x50c617;};'use strict';var _=require(_0x1976('0x0'));var util=require('util');var logger=require(_0x1976('0x1'))(_0x1976('0x2'));var moment=require(_0x1976('0x3'));var BPromise=require('bluebird');var rp=require(_0x1976('0x4'));var fs=require('fs');var path=require(_0x1976('0x5'));var rimraf=require(_0x1976('0x6'));var config=require(_0x1976('0x7'));var attributes=require(_0x1976('0x8'));module[_0x1976('0x9')]=function(_0x2706ff,_0x2b5b3f){return _0x2706ff['define'](_0x1976('0xa'),attributes,{'tableName':_0x1976('0xb'),'paranoid':![],'indexes':[{'name':_0x1976('0xc'),'fields':[_0x1976('0xd')],'type':_0x1976('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x3c557c,_0xe8a93f,_0x5298dc){var _0x3b0aea=_0x2706ff['models'];var _0x2e61d7=_0x3c557c['get']({'plain':!![]});if(_0x2e61d7['direction'][_0x1976('0xf')]()==='in'||_0x2e61d7[_0x1976('0x10')][_0x1976('0xf')]()===_0x1976('0x11')&&!_0x2e61d7[_0x1976('0x12')]&&!_[_0x1976('0x13')](_0x2e61d7[_0x1976('0x14')])){_0x3b0aea[_0x1976('0x15')][_0x1976('0x16')]({'where':{'id':_0x2e61d7[_0x1976('0x17')]}})[_0x1976('0x18')](function(_0x3ec069){if(_0x3ec069){_0x3ec069[_0x1976('0x19')]({'lastMsgAt':_0x2e61d7['createdAt'],'lastMsgDirection':_0x2e61d7[_0x1976('0x10')]['toLowerCase']()});}})[_0x1976('0x1a')](function(_0x3bf211){console[_0x1976('0x1b')](_0x3bf211);});}_0x5298dc();}},'charset':_0x1976('0x1c'),'collate':_0x1976('0x1d')});};