8ec236ffff908fa7660921b78c660c1473bd1b3b
[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 _0x3ac3=['findOne','FaxInteractionId','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','path','rimraf','../../config/environment','./faxMessage.attributes','exports','fax_messages','fti_fax_messages','body','FULLTEXT','models','direction','toLowerCase','isNil','UserId','FaxInteraction'];(function(_0x2446fa,_0x6a50e0){var _0x38bf4f=function(_0x357eb3){while(--_0x357eb3){_0x2446fa['push'](_0x2446fa['shift']());}};_0x38bf4f(++_0x6a50e0);}(_0x3ac3,0x19c));var _0x33ac=function(_0x220afa,_0xf5f6cc){_0x220afa=_0x220afa-0x0;var _0x1b79d1=_0x3ac3[_0x220afa];return _0x1b79d1;};'use strict';var _=require(_0x33ac('0x0'));var util=require(_0x33ac('0x1'));var logger=require(_0x33ac('0x2'))(_0x33ac('0x3'));var moment=require(_0x33ac('0x4'));var BPromise=require('bluebird');var rp=require('request-promise');var fs=require('fs');var path=require(_0x33ac('0x5'));var rimraf=require(_0x33ac('0x6'));var config=require(_0x33ac('0x7'));var attributes=require(_0x33ac('0x8'));module[_0x33ac('0x9')]=function(_0x32130b,_0x20523b){return _0x32130b['define']('FaxMessage',attributes,{'tableName':_0x33ac('0xa'),'paranoid':![],'indexes':[{'name':_0x33ac('0xb'),'fields':[_0x33ac('0xc')],'type':_0x33ac('0xd')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x559cbf,_0x4bd79b,_0x522616){var _0x4324c1=_0x32130b[_0x33ac('0xe')];var _0x2e41db=_0x559cbf['get']({'plain':!![]});if(_0x2e41db[_0x33ac('0xf')][_0x33ac('0x10')]()==='in'||_0x2e41db['direction'][_0x33ac('0x10')]()==='out'&&!_0x2e41db['secret']&&!_[_0x33ac('0x11')](_0x2e41db[_0x33ac('0x12')])){_0x4324c1[_0x33ac('0x13')][_0x33ac('0x14')]({'where':{'id':_0x2e41db[_0x33ac('0x15')]}})['then'](function(_0x2eb220){if(_0x2eb220){_0x2eb220['update']({'lastMsgAt':_0x2e41db[_0x33ac('0x16')],'lastMsgDirection':_0x2e41db['direction'][_0x33ac('0x10')]()});}})[_0x33ac('0x17')](function(_0x4901a9){console[_0x33ac('0x18')](_0x4901a9);});}_0x522616();}},'charset':_0x33ac('0x19'),'collate':_0x33ac('0x1a')});};