03bbcffdb5ce31f7b9236f7b084d55407fe0372f
[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 _0x9fc5=['localhost','socket.io-emitter','./voiceExtension.socket','register','request','then','info','VoiceExtension,\x20%s,\x20%s','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetVoiceExtension','findAll','options','raw','limit','include','map','attributes','model','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults'];(function(_0x4e444b,_0x193e6b){var _0x38d910=function(_0x44f762){while(--_0x44f762){_0x4e444b['push'](_0x4e444b['shift']());}};_0x38d910(++_0x193e6b);}(_0x9fc5,0xb6));var _0x59fc=function(_0x404cde,_0x27b51c){_0x404cde=_0x404cde-0x0;var _0x139882=_0x9fc5[_0x404cde];return _0x139882;};'use strict';var _=require('lodash');var util=require(_0x59fc('0x0'));var moment=require(_0x59fc('0x1'));var BPromise=require('bluebird');var rs=require(_0x59fc('0x2'));var fs=require('fs');var Redis=require(_0x59fc('0x3'));var db=require(_0x59fc('0x4'))['db'];var utils=require(_0x59fc('0x5'));var logger=require(_0x59fc('0x6'))(_0x59fc('0x7'));var config=require(_0x59fc('0x8'));var jayson=require(_0x59fc('0x9'));var client=jayson['client'][_0x59fc('0xa')]({'port':0x232a});config[_0x59fc('0xb')]=_[_0x59fc('0xc')](config['redis'],{'host':_0x59fc('0xd'),'port':0x18eb});var socket=require(_0x59fc('0xe'))(new Redis(config[_0x59fc('0xb')]));require(_0x59fc('0xf'))[_0x59fc('0x10')](socket);function respondWithRpcPromise(_0x212ec8,_0x2556f8,_0x4afc93){return new BPromise(function(_0x2de019,_0x33364e){return client[_0x59fc('0x11')](_0x212ec8,_0x4afc93)[_0x59fc('0x12')](function(_0x29e599){logger[_0x59fc('0x13')](_0x59fc('0x14'),_0x2556f8,'request\x20sent');logger[_0x59fc('0x15')](_0x59fc('0x16'),_0x2556f8,_0x59fc('0x17'),JSON[_0x59fc('0x18')](_0x29e599));if(_0x29e599[_0x59fc('0x19')]){if(_0x29e599[_0x59fc('0x19')][_0x59fc('0x1a')]===0x1f4){logger[_0x59fc('0x19')](_0x59fc('0x14'),_0x2556f8,_0x29e599[_0x59fc('0x19')][_0x59fc('0x1b')]);return _0x33364e(_0x29e599['error'][_0x59fc('0x1b')]);}logger[_0x59fc('0x19')]('VoiceExtension,\x20%s,\x20%s',_0x2556f8,_0x29e599[_0x59fc('0x19')][_0x59fc('0x1b')]);return _0x2de019(_0x29e599[_0x59fc('0x19')][_0x59fc('0x1b')]);}else{logger[_0x59fc('0x13')]('VoiceExtension,\x20%s,\x20%s',_0x2556f8,_0x59fc('0x17'));_0x2de019(_0x29e599[_0x59fc('0x1c')][_0x59fc('0x1b')]);}})[_0x59fc('0x1d')](function(_0x395ede){logger[_0x59fc('0x19')](_0x59fc('0x14'),_0x2556f8,_0x395ede);_0x33364e(_0x395ede);});});}exports[_0x59fc('0x1e')]=function(_0x58a0bb){var _0x153c58=this;return new Promise(function(_0x530c11,_0xdcfddb){return db['VoiceExtension'][_0x59fc('0x1f')]({'raw':_0x58a0bb[_0x59fc('0x20')]?_0x58a0bb[_0x59fc('0x20')][_0x59fc('0x21')]===undefined?!![]:![]:!![],'where':_0x58a0bb[_0x59fc('0x20')]?_0x58a0bb[_0x59fc('0x20')]['where']||null:null,'attributes':_0x58a0bb[_0x59fc('0x20')]?_0x58a0bb[_0x59fc('0x20')]['attributes']||null:null,'limit':_0x58a0bb['options']?_0x58a0bb[_0x59fc('0x20')][_0x59fc('0x22')]||null:null,'include':_0x58a0bb[_0x59fc('0x20')]?_0x58a0bb[_0x59fc('0x20')][_0x59fc('0x23')]?_[_0x59fc('0x24')](_0x58a0bb[_0x59fc('0x20')][_0x59fc('0x23')],function(_0x1bfbe0){return{'model':db[_0x1bfbe0['model']],'as':_0x1bfbe0['as'],'attributes':_0x1bfbe0[_0x59fc('0x25')],'include':_0x1bfbe0['include']?_[_0x59fc('0x24')](_0x1bfbe0['include'],function(_0x2b9e06){return{'model':db[_0x2b9e06[_0x59fc('0x26')]],'as':_0x2b9e06['as'],'attributes':_0x2b9e06['attributes'],'include':_0x2b9e06[_0x59fc('0x23')]?_[_0x59fc('0x24')](_0x2b9e06['include'],function(_0x1304ae){return{'model':db[_0x1304ae[_0x59fc('0x26')]],'as':_0x1304ae['as'],'attributes':_0x1304ae[_0x59fc('0x25')]};}):[]};}):[]};}):[]:[]})[_0x59fc('0x12')](function(_0x252fa4){logger['info'](_0x59fc('0x1e'),_0x58a0bb);logger[_0x59fc('0x15')](_0x59fc('0x1e'),_0x58a0bb,JSON['stringify'](_0x252fa4));_0x530c11(_0x252fa4);})[_0x59fc('0x1d')](function(_0x1dd1a1){logger[_0x59fc('0x19')](_0x59fc('0x1e'),_0x1dd1a1[_0x59fc('0x1b')],_0x58a0bb);_0xdcfddb(_0x153c58[_0x59fc('0x19')](0x1f4,_0x1dd1a1[_0x59fc('0x1b')]));});});};