cf55bee9d04c66366543b19775349ea13ac62ee3
[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 _0x43b9=['fti_fax_messages','body','FULLTEXT','direction','toLowerCase','out','secret','isNil','UserId','FaxInteraction','FaxInteractionId','then','createdAt','error','utf8mb4','utf8mb4_unicode_ci','lodash','api','moment','bluebird','request-promise','rimraf','../../config/environment','./faxMessage.attributes','FaxMessage','fax_messages'];(function(_0x36560d,_0x24b47b){var _0x4cb2a8=function(_0x2cabaf){while(--_0x2cabaf){_0x36560d['push'](_0x36560d['shift']());}};_0x4cb2a8(++_0x24b47b);}(_0x43b9,0x1ca));var _0x943b=function(_0x4b1a19,_0x372bc1){_0x4b1a19=_0x4b1a19-0x0;var _0x229657=_0x43b9[_0x4b1a19];return _0x229657;};'use strict';var _=require(_0x943b('0x0'));var util=require('util');var logger=require('../../config/logger')(_0x943b('0x1'));var moment=require(_0x943b('0x2'));var BPromise=require(_0x943b('0x3'));var rp=require(_0x943b('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0x943b('0x5'));var config=require(_0x943b('0x6'));var attributes=require(_0x943b('0x7'));module['exports']=function(_0x366eff,_0x2961ac){return _0x366eff['define'](_0x943b('0x8'),attributes,{'tableName':_0x943b('0x9'),'paranoid':![],'indexes':[{'name':_0x943b('0xa'),'fields':[_0x943b('0xb')],'type':_0x943b('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x5e169c,_0x11c068,_0x29d52c){var _0x47c0dc=_0x366eff['models'];var _0x45661f=_0x5e169c['get']({'plain':!![]});if(_0x45661f[_0x943b('0xd')][_0x943b('0xe')]()==='in'||_0x45661f[_0x943b('0xd')][_0x943b('0xe')]()===_0x943b('0xf')&&!_0x45661f[_0x943b('0x10')]&&!_[_0x943b('0x11')](_0x45661f[_0x943b('0x12')])){_0x47c0dc[_0x943b('0x13')]['findOne']({'where':{'id':_0x45661f[_0x943b('0x14')]}})[_0x943b('0x15')](function(_0x274b52){if(_0x274b52){_0x274b52['update']({'lastMsgAt':_0x45661f[_0x943b('0x16')],'lastMsgDirection':_0x45661f['direction'][_0x943b('0xe')]()});}})['catch'](function(_0x3639fb){console[_0x943b('0x17')](_0x3639fb);});}_0x29d52c();}},'charset':_0x943b('0x18'),'collate':_0x943b('0x19')});};