Built motion from commit 936e8062.|2.5.33
[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 _0x126e=['where','limit','include','map','attributes','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./voiceExtension.socket','then','info','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','VoiceExtension,\x20%s,\x20%s','message','result','catch','GetVoiceExtension','VoiceExtension','findAll','options','raw'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x126e,0x108));var _0xe126=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0x126e[_0x3bf83f];return _0x22c4a9;};'use strict';var _=require('lodash');var util=require(_0xe126('0x0'));var moment=require(_0xe126('0x1'));var BPromise=require(_0xe126('0x2'));var rs=require(_0xe126('0x3'));var fs=require('fs');var Redis=require(_0xe126('0x4'));var db=require(_0xe126('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xe126('0x6'))(_0xe126('0x7'));var config=require(_0xe126('0x8'));var jayson=require(_0xe126('0x9'));var client=jayson[_0xe126('0xa')][_0xe126('0xb')]({'port':0x232a});config[_0xe126('0xc')]=_['defaults'](config[_0xe126('0xc')],{'host':_0xe126('0xd'),'port':0x18eb});var socket=require(_0xe126('0xe'))(new Redis(config[_0xe126('0xc')]));require(_0xe126('0xf'))['register'](socket);function respondWithRpcPromise(_0x1bc461,_0x1708a0,_0x5e3e34){return new BPromise(function(_0xd69bf4,_0x2ac33c){return client['request'](_0x1bc461,_0x5e3e34)[_0xe126('0x10')](function(_0x5bd113){logger[_0xe126('0x11')]('VoiceExtension,\x20%s,\x20%s',_0x1708a0,_0xe126('0x12'));logger[_0xe126('0x13')](_0xe126('0x14'),_0x1708a0,_0xe126('0x12'),JSON[_0xe126('0x15')](_0x5bd113));if(_0x5bd113[_0xe126('0x16')]){if(_0x5bd113[_0xe126('0x16')]['code']===0x1f4){logger[_0xe126('0x16')](_0xe126('0x17'),_0x1708a0,_0x5bd113['error'][_0xe126('0x18')]);return _0x2ac33c(_0x5bd113[_0xe126('0x16')][_0xe126('0x18')]);}logger[_0xe126('0x16')]('VoiceExtension,\x20%s,\x20%s',_0x1708a0,_0x5bd113[_0xe126('0x16')][_0xe126('0x18')]);return _0xd69bf4(_0x5bd113[_0xe126('0x16')]['message']);}else{logger[_0xe126('0x11')]('VoiceExtension,\x20%s,\x20%s',_0x1708a0,_0xe126('0x12'));_0xd69bf4(_0x5bd113[_0xe126('0x19')][_0xe126('0x18')]);}})[_0xe126('0x1a')](function(_0x3f3dfc){logger[_0xe126('0x16')](_0xe126('0x17'),_0x1708a0,_0x3f3dfc);_0x2ac33c(_0x3f3dfc);});});}exports[_0xe126('0x1b')]=function(_0x5cc73b){var _0x3e0a77=this;return new Promise(function(_0x614bde,_0x35ab64){return db[_0xe126('0x1c')][_0xe126('0x1d')]({'raw':_0x5cc73b[_0xe126('0x1e')]?_0x5cc73b[_0xe126('0x1e')][_0xe126('0x1f')]===undefined?!![]:![]:!![],'where':_0x5cc73b['options']?_0x5cc73b['options'][_0xe126('0x20')]||null:null,'attributes':_0x5cc73b[_0xe126('0x1e')]?_0x5cc73b[_0xe126('0x1e')]['attributes']||null:null,'limit':_0x5cc73b['options']?_0x5cc73b['options'][_0xe126('0x21')]||null:null,'include':_0x5cc73b[_0xe126('0x1e')]?_0x5cc73b['options'][_0xe126('0x22')]?_[_0xe126('0x23')](_0x5cc73b[_0xe126('0x1e')][_0xe126('0x22')],function(_0x532409){return{'model':db[_0x532409['model']],'as':_0x532409['as'],'attributes':_0x532409[_0xe126('0x24')],'include':_0x532409['include']?_[_0xe126('0x23')](_0x532409[_0xe126('0x22')],function(_0x630bcc){return{'model':db[_0x630bcc['model']],'as':_0x630bcc['as'],'attributes':_0x630bcc[_0xe126('0x24')],'include':_0x630bcc[_0xe126('0x22')]?_['map'](_0x630bcc[_0xe126('0x22')],function(_0x259059){return{'model':db[_0x259059['model']],'as':_0x259059['as'],'attributes':_0x259059[_0xe126('0x24')]};}):[]};}):[]};}):[]:[]})[_0xe126('0x10')](function(_0x29dec4){logger[_0xe126('0x11')]('GetVoiceExtension',_0x5cc73b);logger[_0xe126('0x13')](_0xe126('0x1b'),_0x5cc73b,JSON['stringify'](_0x29dec4));_0x614bde(_0x29dec4);})['catch'](function(_0x267582){logger['error'](_0xe126('0x1b'),_0x267582[_0xe126('0x18')],_0x5cc73b);_0x35ab64(_0x3e0a77[_0xe126('0x16')](0x1f4,_0x267582['message']));});});};