Built motion from commit 953226e6.|2.6.32
[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 _0x8bc3=['redis','defaults','./voiceExtension.socket','register','request','then','debug','error','code','message','VoiceExtension,\x20%s,\x20%s','request\x20sent','result','catch','VoiceExtension','findAll','options','where','limit','include','map','model','attributes','info','GetVoiceExtension','lodash','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x8bc3,0x82));var _0x38bc=function(_0x27b08a,_0x5166cd){_0x27b08a=_0x27b08a-0x0;var _0x1af9b9=_0x8bc3[_0x27b08a];return _0x1af9b9;};'use strict';var _=require(_0x38bc('0x0'));var util=require('util');var moment=require(_0x38bc('0x1'));var BPromise=require('bluebird');var rs=require(_0x38bc('0x2'));var fs=require('fs');var Redis=require(_0x38bc('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x38bc('0x4'));var logger=require(_0x38bc('0x5'))(_0x38bc('0x6'));var config=require(_0x38bc('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x38bc('0x8')][_0x38bc('0x9')]({'port':0x232a});config[_0x38bc('0xa')]=_[_0x38bc('0xb')](config[_0x38bc('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x38bc('0xa')]));require(_0x38bc('0xc'))[_0x38bc('0xd')](socket);function respondWithRpcPromise(_0x35ca89,_0x4b592a,_0x31ae45){return new BPromise(function(_0x122a46,_0x877def){return client[_0x38bc('0xe')](_0x35ca89,_0x31ae45)[_0x38bc('0xf')](function(_0x52abe8){logger['info']('VoiceExtension,\x20%s,\x20%s',_0x4b592a,'request\x20sent');logger[_0x38bc('0x10')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x4b592a,'request\x20sent',JSON['stringify'](_0x52abe8));if(_0x52abe8['error']){if(_0x52abe8[_0x38bc('0x11')][_0x38bc('0x12')]===0x1f4){logger[_0x38bc('0x11')]('VoiceExtension,\x20%s,\x20%s',_0x4b592a,_0x52abe8[_0x38bc('0x11')][_0x38bc('0x13')]);return _0x877def(_0x52abe8[_0x38bc('0x11')][_0x38bc('0x13')]);}logger[_0x38bc('0x11')](_0x38bc('0x14'),_0x4b592a,_0x52abe8[_0x38bc('0x11')][_0x38bc('0x13')]);return _0x122a46(_0x52abe8['error'][_0x38bc('0x13')]);}else{logger['info'](_0x38bc('0x14'),_0x4b592a,_0x38bc('0x15'));_0x122a46(_0x52abe8[_0x38bc('0x16')][_0x38bc('0x13')]);}})[_0x38bc('0x17')](function(_0x405366){logger['error'](_0x38bc('0x14'),_0x4b592a,_0x405366);_0x877def(_0x405366);});});}exports['GetVoiceExtension']=function(_0x5608be){var _0x465d0a=this;return new Promise(function(_0x2c54ac,_0x325b14){return db[_0x38bc('0x18')][_0x38bc('0x19')]({'raw':_0x5608be[_0x38bc('0x1a')]?_0x5608be[_0x38bc('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x5608be['options']?_0x5608be[_0x38bc('0x1a')][_0x38bc('0x1b')]||null:null,'attributes':_0x5608be['options']?_0x5608be[_0x38bc('0x1a')]['attributes']||null:null,'limit':_0x5608be[_0x38bc('0x1a')]?_0x5608be[_0x38bc('0x1a')][_0x38bc('0x1c')]||null:null,'include':_0x5608be['options']?_0x5608be[_0x38bc('0x1a')][_0x38bc('0x1d')]?_[_0x38bc('0x1e')](_0x5608be['options'][_0x38bc('0x1d')],function(_0x3daed5){return{'model':db[_0x3daed5[_0x38bc('0x1f')]],'as':_0x3daed5['as'],'attributes':_0x3daed5[_0x38bc('0x20')],'include':_0x3daed5['include']?_['map'](_0x3daed5[_0x38bc('0x1d')],function(_0x114cc8){return{'model':db[_0x114cc8[_0x38bc('0x1f')]],'as':_0x114cc8['as'],'attributes':_0x114cc8[_0x38bc('0x20')],'include':_0x114cc8['include']?_['map'](_0x114cc8['include'],function(_0x456a78){return{'model':db[_0x456a78[_0x38bc('0x1f')]],'as':_0x456a78['as'],'attributes':_0x456a78[_0x38bc('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x33f6cf){logger[_0x38bc('0x21')]('GetVoiceExtension',_0x5608be);logger['debug'](_0x38bc('0x22'),_0x5608be,JSON['stringify'](_0x33f6cf));_0x2c54ac(_0x33f6cf);})['catch'](function(_0x3d224c){logger[_0x38bc('0x11')](_0x38bc('0x22'),_0x3d224c[_0x38bc('0x13')],_0x5608be);_0x325b14(_0x465d0a[_0x38bc('0x11')](0x1f4,_0x3d224c['message']));});});};