e6ad717f1d0c091539fa2bd9bdc211a15d50791b
[motion2.git] / server / api / openchannelApplication / openchannelApplication.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 _0x0b5b=['debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','error','message','result','catch','UpdateOpenchannelApplication','OpenchannelApplication','update','body','options','raw','where','attributes','limit','stringify','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','then','info','OpenchannelApplication,\x20%s,\x20%s','request\x20sent'];(function(_0x3955fa,_0x346a70){var _0x3e89d5=function(_0x47584f){while(--_0x47584f){_0x3955fa['push'](_0x3955fa['shift']());}};_0x3e89d5(++_0x346a70);}(_0x0b5b,0x15a));var _0xb0b5=function(_0x202b4e,_0x490122){_0x202b4e=_0x202b4e-0x0;var _0x4a71a9=_0x0b5b[_0x202b4e];return _0x4a71a9;};'use strict';var _=require('lodash');var util=require(_0xb0b5('0x0'));var moment=require(_0xb0b5('0x1'));var BPromise=require(_0xb0b5('0x2'));var rs=require(_0xb0b5('0x3'));var fs=require('fs');var Redis=require(_0xb0b5('0x4'));var db=require(_0xb0b5('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xb0b5('0x6'))('rpc');var config=require(_0xb0b5('0x7'));var jayson=require(_0xb0b5('0x8'));var client=jayson[_0xb0b5('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5ec948,_0x1105c1,_0x574d01){return new BPromise(function(_0xfd39cf,_0x35e3f7){return client['request'](_0x5ec948,_0x574d01)[_0xb0b5('0xa')](function(_0x4d029a){logger[_0xb0b5('0xb')](_0xb0b5('0xc'),_0x1105c1,_0xb0b5('0xd'));logger[_0xb0b5('0xe')](_0xb0b5('0xf'),_0x1105c1,_0xb0b5('0xd'),JSON['stringify'](_0x4d029a));if(_0x4d029a['error']){if(_0x4d029a['error']['code']===0x1f4){logger[_0xb0b5('0x10')](_0xb0b5('0xc'),_0x1105c1,_0x4d029a[_0xb0b5('0x10')][_0xb0b5('0x11')]);return _0x35e3f7(_0x4d029a['error']['message']);}logger[_0xb0b5('0x10')](_0xb0b5('0xc'),_0x1105c1,_0x4d029a['error'][_0xb0b5('0x11')]);return _0xfd39cf(_0x4d029a[_0xb0b5('0x10')][_0xb0b5('0x11')]);}else{logger['info'](_0xb0b5('0xc'),_0x1105c1,_0xb0b5('0xd'));_0xfd39cf(_0x4d029a[_0xb0b5('0x12')][_0xb0b5('0x11')]);}})[_0xb0b5('0x13')](function(_0x6b7075){logger['error'](_0xb0b5('0xc'),_0x1105c1,_0x6b7075);_0x35e3f7(_0x6b7075);});});}exports[_0xb0b5('0x14')]=function(_0x8b9022){var _0x584a31=this;return new Promise(function(_0x3a21ea,_0x533b55){return db[_0xb0b5('0x15')][_0xb0b5('0x16')](_0x8b9022[_0xb0b5('0x17')],{'raw':_0x8b9022[_0xb0b5('0x18')]?_0x8b9022[_0xb0b5('0x18')][_0xb0b5('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x8b9022[_0xb0b5('0x18')]?_0x8b9022['options'][_0xb0b5('0x1a')]||null:null,'attributes':_0x8b9022['options']?_0x8b9022[_0xb0b5('0x18')][_0xb0b5('0x1b')]||null:null,'limit':_0x8b9022[_0xb0b5('0x18')]?_0x8b9022[_0xb0b5('0x18')][_0xb0b5('0x1c')]||null:null})['then'](function(_0x918e3b){logger[_0xb0b5('0xb')](_0xb0b5('0x14'),_0x8b9022);logger['debug'](_0xb0b5('0x14'),_0x8b9022,JSON[_0xb0b5('0x1d')](_0x918e3b));_0x3a21ea(_0x918e3b);})[_0xb0b5('0x13')](function(_0x39f2b2){logger[_0xb0b5('0x10')](_0xb0b5('0x14'),_0x39f2b2[_0xb0b5('0x11')],_0x8b9022);_0x533b55(_0x584a31[_0xb0b5('0x10')](0x1f4,_0x39f2b2['message']));});});};