20e7441b551f8a82245dd73c754b83babbb64557
[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 _0xbaad=['findOne','FaxInteractionId','update','catch','utf8mb4','utf8mb4_unicode_ci','lodash','util','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./faxMessage.attributes','exports','FaxMessage','fax_messages','fti_fax_messages','FULLTEXT','models','direction','toLowerCase','out','secret'];(function(_0x311c35,_0x534915){var _0x5cc50c=function(_0x3ad680){while(--_0x3ad680){_0x311c35['push'](_0x311c35['shift']());}};_0x5cc50c(++_0x534915);}(_0xbaad,0x18c));var _0xdbaa=function(_0x17d7a0,_0x2d0249){_0x17d7a0=_0x17d7a0-0x0;var _0x14466f=_0xbaad[_0x17d7a0];return _0x14466f;};'use strict';var _=require(_0xdbaa('0x0'));var util=require(_0xdbaa('0x1'));var logger=require('../../config/logger')(_0xdbaa('0x2'));var moment=require(_0xdbaa('0x3'));var BPromise=require(_0xdbaa('0x4'));var rp=require(_0xdbaa('0x5'));var fs=require('fs');var path=require(_0xdbaa('0x6'));var rimraf=require(_0xdbaa('0x7'));var config=require(_0xdbaa('0x8'));var attributes=require(_0xdbaa('0x9'));module[_0xdbaa('0xa')]=function(_0x3cbe83,_0x1ea8fe){return _0x3cbe83['define'](_0xdbaa('0xb'),attributes,{'tableName':_0xdbaa('0xc'),'paranoid':![],'indexes':[{'name':_0xdbaa('0xd'),'fields':['body'],'type':_0xdbaa('0xe')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x2c6b62,_0x3ab087,_0x571460){var _0x5ec874=_0x3cbe83[_0xdbaa('0xf')];var _0x470e5c=_0x2c6b62['get']({'plain':!![]});if(_0x470e5c[_0xdbaa('0x10')][_0xdbaa('0x11')]()==='in'||_0x470e5c['direction'][_0xdbaa('0x11')]()===_0xdbaa('0x12')&&!_0x470e5c[_0xdbaa('0x13')]&&!_['isNil'](_0x470e5c['UserId'])){_0x5ec874['FaxInteraction'][_0xdbaa('0x14')]({'where':{'id':_0x470e5c[_0xdbaa('0x15')]}})['then'](function(_0x4dae4c){if(_0x4dae4c){_0x4dae4c[_0xdbaa('0x16')]({'lastMsgAt':_0x470e5c['createdAt'],'lastMsgDirection':_0x470e5c['direction'][_0xdbaa('0x11')]()});}})[_0xdbaa('0x17')](function(_0x2f75e3){console['error'](_0x2f75e3);});}_0x571460();}},'charset':_0xdbaa('0x18'),'collate':_0xdbaa('0x19')});};