Built motion from commit 3c2ce842.|2.6.31
[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 _0x16a6=['ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','redis','defaults','socket.io-emitter','./voiceExtension.socket','request','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','GetVoiceExtension','options','attributes','limit','include','model','map','lodash','util','bluebird','randomstring'];(function(_0x43c970,_0x2540cb){var _0x1ca73a=function(_0x1b87c0){while(--_0x1b87c0){_0x43c970['push'](_0x43c970['shift']());}};_0x1ca73a(++_0x2540cb);}(_0x16a6,0x15c));var _0x616a=function(_0x2dadb9,_0x42cfe6){_0x2dadb9=_0x2dadb9-0x0;var _0x2f0097=_0x16a6[_0x2dadb9];return _0x2f0097;};'use strict';var _=require(_0x616a('0x0'));var util=require(_0x616a('0x1'));var moment=require('moment');var BPromise=require(_0x616a('0x2'));var rs=require(_0x616a('0x3'));var fs=require('fs');var Redis=require(_0x616a('0x4'));var db=require(_0x616a('0x5'))['db'];var utils=require(_0x616a('0x6'));var logger=require(_0x616a('0x7'))('rpc');var config=require(_0x616a('0x8'));var jayson=require(_0x616a('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0x616a('0xa')]=_[_0x616a('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x616a('0xc'))(new Redis(config['redis']));require(_0x616a('0xd'))['register'](socket);function respondWithRpcPromise(_0x3256a1,_0x235970,_0x2a4984){return new BPromise(function(_0x57d339,_0x1ab052){return client[_0x616a('0xe')](_0x3256a1,_0x2a4984)[_0x616a('0xf')](function(_0x47674e){logger[_0x616a('0x10')](_0x616a('0x11'),_0x235970,_0x616a('0x12'));logger[_0x616a('0x13')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x235970,_0x616a('0x12'),JSON[_0x616a('0x14')](_0x47674e));if(_0x47674e[_0x616a('0x15')]){if(_0x47674e[_0x616a('0x15')][_0x616a('0x16')]===0x1f4){logger['error'](_0x616a('0x11'),_0x235970,_0x47674e[_0x616a('0x15')][_0x616a('0x17')]);return _0x1ab052(_0x47674e[_0x616a('0x15')][_0x616a('0x17')]);}logger['error'](_0x616a('0x11'),_0x235970,_0x47674e[_0x616a('0x15')]['message']);return _0x57d339(_0x47674e['error'][_0x616a('0x17')]);}else{logger[_0x616a('0x10')](_0x616a('0x11'),_0x235970,'request\x20sent');_0x57d339(_0x47674e[_0x616a('0x18')][_0x616a('0x17')]);}})['catch'](function(_0x535d2b){logger[_0x616a('0x15')](_0x616a('0x11'),_0x235970,_0x535d2b);_0x1ab052(_0x535d2b);});});}exports[_0x616a('0x19')]=function(_0x31b711){var _0x505b9f=this;return new Promise(function(_0x499132,_0x5568fd){return db['VoiceExtension']['findAll']({'raw':_0x31b711['options']?_0x31b711[_0x616a('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x31b711[_0x616a('0x1a')]?_0x31b711[_0x616a('0x1a')]['where']||null:null,'attributes':_0x31b711[_0x616a('0x1a')]?_0x31b711[_0x616a('0x1a')][_0x616a('0x1b')]||null:null,'limit':_0x31b711[_0x616a('0x1a')]?_0x31b711['options'][_0x616a('0x1c')]||null:null,'include':_0x31b711[_0x616a('0x1a')]?_0x31b711[_0x616a('0x1a')][_0x616a('0x1d')]?_['map'](_0x31b711[_0x616a('0x1a')]['include'],function(_0x30c1a){return{'model':db[_0x30c1a[_0x616a('0x1e')]],'as':_0x30c1a['as'],'attributes':_0x30c1a['attributes'],'include':_0x30c1a['include']?_['map'](_0x30c1a[_0x616a('0x1d')],function(_0x7ebd63){return{'model':db[_0x7ebd63[_0x616a('0x1e')]],'as':_0x7ebd63['as'],'attributes':_0x7ebd63[_0x616a('0x1b')],'include':_0x7ebd63['include']?_[_0x616a('0x1f')](_0x7ebd63[_0x616a('0x1d')],function(_0x195b73){return{'model':db[_0x195b73[_0x616a('0x1e')]],'as':_0x195b73['as'],'attributes':_0x195b73[_0x616a('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x616a('0xf')](function(_0x41a22d){logger['info'](_0x616a('0x19'),_0x31b711);logger[_0x616a('0x13')]('GetVoiceExtension',_0x31b711,JSON[_0x616a('0x14')](_0x41a22d));_0x499132(_0x41a22d);})['catch'](function(_0x5f00d0){logger[_0x616a('0x15')](_0x616a('0x19'),_0x5f00d0[_0x616a('0x17')],_0x31b711);_0x5568fd(_0x505b9f['error'](0x1f4,_0x5f00d0[_0x616a('0x17')]));});});};