d3c0b104e10b399e358310043b43709771dc5842
[motion2.git] / server / api / voiceExtension / voiceExtension.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 _0x873a=['error','code','VoiceExtension,\x20%s,\x20%s','message','catch','GetVoiceExtension','VoiceExtension','options','raw','limit','attributes','include','model','map','then','info','debug','stringify','lodash','util','moment','randomstring','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','./voiceExtension.socket','register','request','request\x20sent','VoiceExtension,\x20%s,\x20%s,\x20%s'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x873a,0x1c2));var _0xa873=function(_0x3acf0f,_0x4736ac){_0x3acf0f=_0x3acf0f-0x0;var _0x48cf9f=_0x873a[_0x3acf0f];return _0x48cf9f;};'use strict';var _=require(_0xa873('0x0'));var util=require(_0xa873('0x1'));var moment=require(_0xa873('0x2'));var BPromise=require('bluebird');var rs=require(_0xa873('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xa873('0x4'));var logger=require(_0xa873('0x5'))('rpc');var config=require(_0xa873('0x6'));var jayson=require(_0xa873('0x7'));var client=jayson['client'][_0xa873('0x8')]({'port':0x232a});config['redis']=_[_0xa873('0x9')](config[_0xa873('0xa')],{'host':_0xa873('0xb'),'port':0x18eb});var socket=require(_0xa873('0xc'))(new Redis(config[_0xa873('0xa')]));require(_0xa873('0xd'))[_0xa873('0xe')](socket);function respondWithRpcPromise(_0x10b82b,_0x44fa49,_0x23c1fa){return new BPromise(function(_0xc2fb4f,_0x4d0270){return client[_0xa873('0xf')](_0x10b82b,_0x23c1fa)['then'](function(_0x2573c9){logger['info']('VoiceExtension,\x20%s,\x20%s',_0x44fa49,_0xa873('0x10'));logger['debug'](_0xa873('0x11'),_0x44fa49,_0xa873('0x10'),JSON['stringify'](_0x2573c9));if(_0x2573c9[_0xa873('0x12')]){if(_0x2573c9[_0xa873('0x12')][_0xa873('0x13')]===0x1f4){logger['error'](_0xa873('0x14'),_0x44fa49,_0x2573c9[_0xa873('0x12')][_0xa873('0x15')]);return _0x4d0270(_0x2573c9['error'][_0xa873('0x15')]);}logger[_0xa873('0x12')](_0xa873('0x14'),_0x44fa49,_0x2573c9['error'][_0xa873('0x15')]);return _0xc2fb4f(_0x2573c9['error'][_0xa873('0x15')]);}else{logger['info'](_0xa873('0x14'),_0x44fa49,_0xa873('0x10'));_0xc2fb4f(_0x2573c9['result'][_0xa873('0x15')]);}})[_0xa873('0x16')](function(_0x34e859){logger['error'](_0xa873('0x14'),_0x44fa49,_0x34e859);_0x4d0270(_0x34e859);});});}exports[_0xa873('0x17')]=function(_0x5af77c){var _0x348492=this;return new Promise(function(_0x2b9238,_0x2e2d5a){return db[_0xa873('0x18')]['findAll']({'raw':_0x5af77c[_0xa873('0x19')]?_0x5af77c[_0xa873('0x19')][_0xa873('0x1a')]===undefined?!![]:![]:!![],'where':_0x5af77c[_0xa873('0x19')]?_0x5af77c[_0xa873('0x19')]['where']||null:null,'attributes':_0x5af77c[_0xa873('0x19')]?_0x5af77c[_0xa873('0x19')]['attributes']||null:null,'limit':_0x5af77c[_0xa873('0x19')]?_0x5af77c['options'][_0xa873('0x1b')]||null:null,'include':_0x5af77c[_0xa873('0x19')]?_0x5af77c[_0xa873('0x19')]['include']?_['map'](_0x5af77c[_0xa873('0x19')]['include'],function(_0x4326f6){return{'model':db[_0x4326f6['model']],'as':_0x4326f6['as'],'attributes':_0x4326f6[_0xa873('0x1c')],'include':_0x4326f6[_0xa873('0x1d')]?_['map'](_0x4326f6[_0xa873('0x1d')],function(_0x9ca1dc){return{'model':db[_0x9ca1dc[_0xa873('0x1e')]],'as':_0x9ca1dc['as'],'attributes':_0x9ca1dc[_0xa873('0x1c')],'include':_0x9ca1dc[_0xa873('0x1d')]?_[_0xa873('0x1f')](_0x9ca1dc[_0xa873('0x1d')],function(_0xae680){return{'model':db[_0xae680[_0xa873('0x1e')]],'as':_0xae680['as'],'attributes':_0xae680[_0xa873('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xa873('0x20')](function(_0xcdae11){logger[_0xa873('0x21')](_0xa873('0x17'),_0x5af77c);logger[_0xa873('0x22')](_0xa873('0x17'),_0x5af77c,JSON[_0xa873('0x23')](_0xcdae11));_0x2b9238(_0xcdae11);})[_0xa873('0x16')](function(_0x222d28){logger[_0xa873('0x12')](_0xa873('0x17'),_0x222d28[_0xa873('0x15')],_0x5af77c);_0x2e2d5a(_0x348492[_0xa873('0x12')](0x1f4,_0x222d28[_0xa873('0x15')]));});});};