087d0ae79c25ee0f07d14a00c9ab2e34d8fb7d3c
[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 _0x53eb=['request-promise','path','rimraf','../../config/environment','exports','FaxMessage','fax_messages','body','FULLTEXT','models','get','direction','toLowerCase','out','secret','isNil','UserId','FaxInteraction','FaxInteractionId','then','update','createdAt','lodash','util','moment','bluebird'];(function(_0x566420,_0x10818b){var _0x399b9e=function(_0x45b45c){while(--_0x45b45c){_0x566420['push'](_0x566420['shift']());}};_0x399b9e(++_0x10818b);}(_0x53eb,0x168));var _0xb53e=function(_0x3cec1c,_0x1b99e1){_0x3cec1c=_0x3cec1c-0x0;var _0x20b7a9=_0x53eb[_0x3cec1c];return _0x20b7a9;};'use strict';var _=require(_0xb53e('0x0'));var util=require(_0xb53e('0x1'));var logger=require('../../config/logger')('api');var moment=require(_0xb53e('0x2'));var BPromise=require(_0xb53e('0x3'));var rp=require(_0xb53e('0x4'));var fs=require('fs');var path=require(_0xb53e('0x5'));var rimraf=require(_0xb53e('0x6'));var config=require(_0xb53e('0x7'));var attributes=require('./faxMessage.attributes');module[_0xb53e('0x8')]=function(_0x391a63,_0x15eb28){return _0x391a63['define'](_0xb53e('0x9'),attributes,{'tableName':_0xb53e('0xa'),'paranoid':![],'indexes':[{'name':'fti_fax_messages','fields':[_0xb53e('0xb')],'type':_0xb53e('0xc')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x27eb2d,_0x49ee53,_0x29ced7){var _0x8b6957=_0x391a63[_0xb53e('0xd')];var _0x4db888=_0x27eb2d[_0xb53e('0xe')]({'plain':!![]});if(_0x4db888[_0xb53e('0xf')][_0xb53e('0x10')]()==='in'||_0x4db888[_0xb53e('0xf')][_0xb53e('0x10')]()===_0xb53e('0x11')&&!_0x4db888[_0xb53e('0x12')]&&!_[_0xb53e('0x13')](_0x4db888[_0xb53e('0x14')])){_0x8b6957[_0xb53e('0x15')]['findOne']({'where':{'id':_0x4db888[_0xb53e('0x16')]}})[_0xb53e('0x17')](function(_0x29f1fb){if(_0x29f1fb){_0x29f1fb[_0xb53e('0x18')]({'lastMsgAt':_0x4db888[_0xb53e('0x19')],'lastMsgDirection':_0x4db888[_0xb53e('0xf')][_0xb53e('0x10')]()});}})['catch'](function(_0x40943c){console['error'](_0x40943c);});}_0x29ced7();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};