Built motion from commit (unavailable).|2.6.0
[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 _0x2ffb=['bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','redis','./voiceExtension.socket','register','request','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','VoiceExtension,\x20%s,\x20%s,\x20%s','error','message','result','VoiceExtension','findAll','options','raw','where','attributes','limit','include','model','map','GetVoiceExtension','stringify','util','moment'];(function(_0x116ff3,_0x28e6d3){var _0x898bfb=function(_0x58efdb){while(--_0x58efdb){_0x116ff3['push'](_0x116ff3['shift']());}};_0x898bfb(++_0x28e6d3);}(_0x2ffb,0x11e));var _0xb2ff=function(_0x349077,_0x2eafb1){_0x349077=_0x349077-0x0;var _0x277000=_0x2ffb[_0x349077];return _0x277000;};'use strict';var _=require('lodash');var util=require(_0xb2ff('0x0'));var moment=require(_0xb2ff('0x1'));var BPromise=require(_0xb2ff('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb2ff('0x3'));var db=require(_0xb2ff('0x4'))['db'];var utils=require(_0xb2ff('0x5'));var logger=require(_0xb2ff('0x6'))(_0xb2ff('0x7'));var config=require(_0xb2ff('0x8'));var jayson=require(_0xb2ff('0x9'));var client=jayson['client'][_0xb2ff('0xa')]({'port':0x232a});config['redis']=_[_0xb2ff('0xb')](config[_0xb2ff('0xc')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb2ff('0xc')]));require(_0xb2ff('0xd'))[_0xb2ff('0xe')](socket);function respondWithRpcPromise(_0x4e8253,_0xbac5b2,_0x5e4530){return new BPromise(function(_0xa8c837,_0x4c3992){return client[_0xb2ff('0xf')](_0x4e8253,_0x5e4530)[_0xb2ff('0x10')](function(_0x23a7d1){logger[_0xb2ff('0x11')](_0xb2ff('0x12'),_0xbac5b2,_0xb2ff('0x13'));logger['debug'](_0xb2ff('0x14'),_0xbac5b2,_0xb2ff('0x13'),JSON['stringify'](_0x23a7d1));if(_0x23a7d1[_0xb2ff('0x15')]){if(_0x23a7d1[_0xb2ff('0x15')]['code']===0x1f4){logger[_0xb2ff('0x15')](_0xb2ff('0x12'),_0xbac5b2,_0x23a7d1[_0xb2ff('0x15')][_0xb2ff('0x16')]);return _0x4c3992(_0x23a7d1[_0xb2ff('0x15')]['message']);}logger['error']('VoiceExtension,\x20%s,\x20%s',_0xbac5b2,_0x23a7d1[_0xb2ff('0x15')][_0xb2ff('0x16')]);return _0xa8c837(_0x23a7d1[_0xb2ff('0x15')][_0xb2ff('0x16')]);}else{logger[_0xb2ff('0x11')](_0xb2ff('0x12'),_0xbac5b2,'request\x20sent');_0xa8c837(_0x23a7d1[_0xb2ff('0x17')][_0xb2ff('0x16')]);}})['catch'](function(_0x2e51f6){logger[_0xb2ff('0x15')](_0xb2ff('0x12'),_0xbac5b2,_0x2e51f6);_0x4c3992(_0x2e51f6);});});}exports['GetVoiceExtension']=function(_0x25466a){var _0x1b44c2=this;return new Promise(function(_0x175ecb,_0x284bd1){return db[_0xb2ff('0x18')][_0xb2ff('0x19')]({'raw':_0x25466a['options']?_0x25466a[_0xb2ff('0x1a')][_0xb2ff('0x1b')]===undefined?!![]:![]:!![],'where':_0x25466a[_0xb2ff('0x1a')]?_0x25466a[_0xb2ff('0x1a')][_0xb2ff('0x1c')]||null:null,'attributes':_0x25466a[_0xb2ff('0x1a')]?_0x25466a[_0xb2ff('0x1a')][_0xb2ff('0x1d')]||null:null,'limit':_0x25466a[_0xb2ff('0x1a')]?_0x25466a[_0xb2ff('0x1a')][_0xb2ff('0x1e')]||null:null,'include':_0x25466a[_0xb2ff('0x1a')]?_0x25466a[_0xb2ff('0x1a')]['include']?_['map'](_0x25466a['options'][_0xb2ff('0x1f')],function(_0xe318f2){return{'model':db[_0xe318f2[_0xb2ff('0x20')]],'as':_0xe318f2['as'],'attributes':_0xe318f2[_0xb2ff('0x1d')],'include':_0xe318f2['include']?_[_0xb2ff('0x21')](_0xe318f2[_0xb2ff('0x1f')],function(_0xd8de5){return{'model':db[_0xd8de5[_0xb2ff('0x20')]],'as':_0xd8de5['as'],'attributes':_0xd8de5[_0xb2ff('0x1d')],'include':_0xd8de5['include']?_[_0xb2ff('0x21')](_0xd8de5[_0xb2ff('0x1f')],function(_0x86bb3b){return{'model':db[_0x86bb3b[_0xb2ff('0x20')]],'as':_0x86bb3b['as'],'attributes':_0x86bb3b[_0xb2ff('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xb2ff('0x10')](function(_0x34e2b0){logger[_0xb2ff('0x11')](_0xb2ff('0x22'),_0x25466a);logger['debug'](_0xb2ff('0x22'),_0x25466a,JSON[_0xb2ff('0x23')](_0x34e2b0));_0x175ecb(_0x34e2b0);})['catch'](function(_0x25ed84){logger[_0xb2ff('0x15')]('GetVoiceExtension',_0x25ed84[_0xb2ff('0x16')],_0x25466a);_0x284bd1(_0x1b44c2[_0xb2ff('0x15')](0x1f4,_0x25ed84[_0xb2ff('0x16')]));});});};