Built motion from commit (unavailable).|2.5.4
[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 _0xcbd1=['catch','GetVoiceExtension','findAll','options','where','attributes','limit','include','map','model','debug','stringify','lodash','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','defaults','redis','./voiceExtension.socket','request','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','error','code','message','result'];(function(_0x1805ce,_0x565a64){var _0x344d75=function(_0x1ec743){while(--_0x1ec743){_0x1805ce['push'](_0x1805ce['shift']());}};_0x344d75(++_0x565a64);}(_0xcbd1,0x90));var _0x1cbd=function(_0x4d2411,_0x4f1439){_0x4d2411=_0x4d2411-0x0;var _0x39cf0c=_0xcbd1[_0x4d2411];return _0x39cf0c;};'use strict';var _=require(_0x1cbd('0x0'));var util=require('util');var moment=require(_0x1cbd('0x1'));var BPromise=require(_0x1cbd('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1cbd('0x3'))['db'];var utils=require(_0x1cbd('0x4'));var logger=require(_0x1cbd('0x5'))(_0x1cbd('0x6'));var config=require('../../config/environment');var jayson=require(_0x1cbd('0x7'));var client=jayson['client'][_0x1cbd('0x8')]({'port':0x232a});config['redis']=_[_0x1cbd('0x9')](config[_0x1cbd('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x1cbd('0xb'))['register'](socket);function respondWithRpcPromise(_0x2ea7a6,_0xe76944,_0x436291){return new BPromise(function(_0x336f3f,_0x406d56){return client[_0x1cbd('0xc')](_0x2ea7a6,_0x436291)[_0x1cbd('0xd')](function(_0x752999){logger[_0x1cbd('0xe')](_0x1cbd('0xf'),_0xe76944,_0x1cbd('0x10'));logger['debug']('VoiceExtension,\x20%s,\x20%s,\x20%s',_0xe76944,_0x1cbd('0x10'),JSON['stringify'](_0x752999));if(_0x752999[_0x1cbd('0x11')]){if(_0x752999[_0x1cbd('0x11')][_0x1cbd('0x12')]===0x1f4){logger[_0x1cbd('0x11')]('VoiceExtension,\x20%s,\x20%s',_0xe76944,_0x752999[_0x1cbd('0x11')]['message']);return _0x406d56(_0x752999[_0x1cbd('0x11')][_0x1cbd('0x13')]);}logger[_0x1cbd('0x11')](_0x1cbd('0xf'),_0xe76944,_0x752999['error'][_0x1cbd('0x13')]);return _0x336f3f(_0x752999[_0x1cbd('0x11')]['message']);}else{logger[_0x1cbd('0xe')](_0x1cbd('0xf'),_0xe76944,_0x1cbd('0x10'));_0x336f3f(_0x752999[_0x1cbd('0x14')]['message']);}})[_0x1cbd('0x15')](function(_0x334a95){logger['error'](_0x1cbd('0xf'),_0xe76944,_0x334a95);_0x406d56(_0x334a95);});});}exports[_0x1cbd('0x16')]=function(_0x275f0f){var _0x30aab5=this;return new Promise(function(_0x4da57c,_0x197d0c){return db['VoiceExtension'][_0x1cbd('0x17')]({'raw':_0x275f0f[_0x1cbd('0x18')]?_0x275f0f[_0x1cbd('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x275f0f[_0x1cbd('0x18')]?_0x275f0f[_0x1cbd('0x18')][_0x1cbd('0x19')]||null:null,'attributes':_0x275f0f[_0x1cbd('0x18')]?_0x275f0f[_0x1cbd('0x18')][_0x1cbd('0x1a')]||null:null,'limit':_0x275f0f[_0x1cbd('0x18')]?_0x275f0f[_0x1cbd('0x18')][_0x1cbd('0x1b')]||null:null,'include':_0x275f0f[_0x1cbd('0x18')]?_0x275f0f['options'][_0x1cbd('0x1c')]?_[_0x1cbd('0x1d')](_0x275f0f[_0x1cbd('0x18')][_0x1cbd('0x1c')],function(_0x41a7b5){return{'model':db[_0x41a7b5['model']],'as':_0x41a7b5['as'],'attributes':_0x41a7b5['attributes'],'include':_0x41a7b5['include']?_[_0x1cbd('0x1d')](_0x41a7b5[_0x1cbd('0x1c')],function(_0x5203a1){return{'model':db[_0x5203a1[_0x1cbd('0x1e')]],'as':_0x5203a1['as'],'attributes':_0x5203a1[_0x1cbd('0x1a')],'include':_0x5203a1['include']?_[_0x1cbd('0x1d')](_0x5203a1[_0x1cbd('0x1c')],function(_0x53e134){return{'model':db[_0x53e134[_0x1cbd('0x1e')]],'as':_0x53e134['as'],'attributes':_0x53e134[_0x1cbd('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x1cbd('0xd')](function(_0x43f7cc){logger[_0x1cbd('0xe')]('GetVoiceExtension',_0x275f0f);logger[_0x1cbd('0x1f')]('GetVoiceExtension',_0x275f0f,JSON[_0x1cbd('0x20')](_0x43f7cc));_0x4da57c(_0x43f7cc);})[_0x1cbd('0x15')](function(_0x560839){logger[_0x1cbd('0x11')](_0x1cbd('0x16'),_0x560839[_0x1cbd('0x13')],_0x275f0f);_0x197d0c(_0x30aab5[_0x1cbd('0x11')](0x1f4,_0x560839[_0x1cbd('0x13')]));});});};