012646e3d8afaa057db25e26df2613fbd610c46f
[motion2.git] / server / api / faxInteraction / faxInteraction.rpc.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 _0x7a11=['rpc','jayson/promise','client','http','localhost','redis','./faxInteraction.socket','info','FaxInteraction,\x20%s,\x20%s','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','FaxInteraction','options','raw','where','limit','then','catch','UpdateFaxInteraction','AddTagsToFaxInteraction','find','body','ids','spread','AddTags','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x3588ce,_0x5c5238){var _0x8cda3f=function(_0xe29311){while(--_0xe29311){_0x3588ce['push'](_0x3588ce['shift']());}};_0x8cda3f(++_0x5c5238);}(_0x7a11,0x175));var _0x17a1=function(_0x3e5086,_0x48f4a2){_0x3e5086=_0x3e5086-0x0;var _0xfeb102=_0x7a11[_0x3e5086];return _0xfeb102;};'use strict';var _=require(_0x17a1('0x0'));var util=require(_0x17a1('0x1'));var moment=require(_0x17a1('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x17a1('0x3'));var db=require(_0x17a1('0x4'))['db'];var utils=require(_0x17a1('0x5'));var logger=require(_0x17a1('0x6'))(_0x17a1('0x7'));var config=require('../../config/environment');var jayson=require(_0x17a1('0x8'));var client=jayson[_0x17a1('0x9')][_0x17a1('0xa')]({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x17a1('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x17a1('0xc')]));require(_0x17a1('0xd'))['register'](socket);function respondWithRpcPromise(_0x3ce60c,_0x9460dc,_0x3a2bd8){return new BPromise(function(_0x3f3774,_0x596155){return client['request'](_0x3ce60c,_0x3a2bd8)['then'](function(_0x1cc3b3){logger[_0x17a1('0xe')](_0x17a1('0xf'),_0x9460dc,'request\x20sent');logger[_0x17a1('0x10')](_0x17a1('0x11'),_0x9460dc,_0x17a1('0x12'),JSON[_0x17a1('0x13')](_0x1cc3b3));if(_0x1cc3b3[_0x17a1('0x14')]){if(_0x1cc3b3['error'][_0x17a1('0x15')]===0x1f4){logger[_0x17a1('0x14')](_0x17a1('0xf'),_0x9460dc,_0x1cc3b3[_0x17a1('0x14')][_0x17a1('0x16')]);return _0x596155(_0x1cc3b3['error'][_0x17a1('0x16')]);}logger['error'](_0x17a1('0xf'),_0x9460dc,_0x1cc3b3[_0x17a1('0x14')][_0x17a1('0x16')]);return _0x3f3774(_0x1cc3b3['error'][_0x17a1('0x16')]);}else{logger['info'](_0x17a1('0xf'),_0x9460dc,_0x17a1('0x12'));_0x3f3774(_0x1cc3b3[_0x17a1('0x17')]['message']);}})['catch'](function(_0x2297f9){logger[_0x17a1('0x14')](_0x17a1('0xf'),_0x9460dc,_0x2297f9);_0x596155(_0x2297f9);});});}exports['UpdateFaxInteraction']=function(_0x19c6cb){var _0x5890b8=this;return new Promise(function(_0x5cfa72,_0x388b38){return db[_0x17a1('0x18')]['update'](_0x19c6cb['body'],{'raw':_0x19c6cb[_0x17a1('0x19')]?_0x19c6cb[_0x17a1('0x19')][_0x17a1('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x19c6cb[_0x17a1('0x19')]?_0x19c6cb[_0x17a1('0x19')][_0x17a1('0x1b')]||null:null,'attributes':_0x19c6cb[_0x17a1('0x19')]?_0x19c6cb[_0x17a1('0x19')]['attributes']||null:null,'limit':_0x19c6cb[_0x17a1('0x19')]?_0x19c6cb[_0x17a1('0x19')][_0x17a1('0x1c')]||null:null})[_0x17a1('0x1d')](function(_0x17b6c6){logger[_0x17a1('0xe')]('UpdateFaxInteraction',_0x19c6cb);logger[_0x17a1('0x10')]('UpdateFaxInteraction',_0x19c6cb,JSON[_0x17a1('0x13')](_0x17b6c6));_0x5cfa72(_0x17b6c6);})[_0x17a1('0x1e')](function(_0x3ba258){logger['error'](_0x17a1('0x1f'),_0x3ba258['message'],_0x19c6cb);_0x388b38(_0x5890b8[_0x17a1('0x14')](0x1f4,_0x3ba258['message']));});});};exports[_0x17a1('0x20')]=function(_0x1b24ac){return new Promise(function(_0x2c0be4,_0x81f1c0){return db[_0x17a1('0x18')][_0x17a1('0x21')]({'where':_0x1b24ac[_0x17a1('0x19')]?_0x1b24ac[_0x17a1('0x19')][_0x17a1('0x1b')]||null:null})[_0x17a1('0x1d')](function(_0x4ec755){if(_0x4ec755){return _0x4ec755['addTags'](_0x1b24ac[_0x17a1('0x22')][_0x17a1('0x23')],_['omit'](_0x1b24ac[_0x17a1('0x22')],['ids','id'])||{});}})[_0x17a1('0x24')](function(_0x3d994d){logger[_0x17a1('0xe')](_0x17a1('0x25'),_0x1b24ac);logger[_0x17a1('0x10')](_0x17a1('0x25'),_0x1b24ac,JSON[_0x17a1('0x13')](_0x3d994d));_0x2c0be4(_0x3d994d);})[_0x17a1('0x1e')](function(_0x1a5789){logger[_0x17a1('0x14')]('AddTags',_0x1a5789[_0x17a1('0x16')],_0x1b24ac);_0x81f1c0(_this[_0x17a1('0x14')](0x1f4,_0x1a5789['message']));});});};