Built motion from commit (unavailable).|2.5.13
[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 _0x6f13=['http','defaults','localhost','socket.io-emitter','redis','./voiceExtension.socket','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceExtension','findAll','options','raw','where','limit','include','attributes','map','model','debug','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x6f13,0x68));var _0x36f1=function(_0x10a7c3,_0x374dc0){_0x10a7c3=_0x10a7c3-0x0;var _0x23b8de=_0x6f13[_0x10a7c3];return _0x23b8de;};'use strict';var _=require(_0x36f1('0x0'));var util=require('util');var moment=require(_0x36f1('0x1'));var BPromise=require(_0x36f1('0x2'));var rs=require(_0x36f1('0x3'));var fs=require('fs');var Redis=require(_0x36f1('0x4'));var db=require(_0x36f1('0x5'))['db'];var utils=require(_0x36f1('0x6'));var logger=require(_0x36f1('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x36f1('0x8'));var client=jayson[_0x36f1('0x9')][_0x36f1('0xa')]({'port':0x232a});config['redis']=_[_0x36f1('0xb')](config['redis'],{'host':_0x36f1('0xc'),'port':0x18eb});var socket=require(_0x36f1('0xd'))(new Redis(config[_0x36f1('0xe')]));require(_0x36f1('0xf'))['register'](socket);function respondWithRpcPromise(_0x3fea98,_0x477f86,_0x49c8b9){return new BPromise(function(_0x48dd24,_0x1ec653){return client['request'](_0x3fea98,_0x49c8b9)[_0x36f1('0x10')](function(_0x9a864e){logger[_0x36f1('0x11')](_0x36f1('0x12'),_0x477f86,_0x36f1('0x13'));logger['debug'](_0x36f1('0x14'),_0x477f86,_0x36f1('0x13'),JSON[_0x36f1('0x15')](_0x9a864e));if(_0x9a864e[_0x36f1('0x16')]){if(_0x9a864e[_0x36f1('0x16')][_0x36f1('0x17')]===0x1f4){logger[_0x36f1('0x16')](_0x36f1('0x12'),_0x477f86,_0x9a864e[_0x36f1('0x16')]['message']);return _0x1ec653(_0x9a864e[_0x36f1('0x16')][_0x36f1('0x18')]);}logger['error'](_0x36f1('0x12'),_0x477f86,_0x9a864e[_0x36f1('0x16')][_0x36f1('0x18')]);return _0x48dd24(_0x9a864e[_0x36f1('0x16')][_0x36f1('0x18')]);}else{logger[_0x36f1('0x11')]('VoiceExtension,\x20%s,\x20%s',_0x477f86,_0x36f1('0x13'));_0x48dd24(_0x9a864e[_0x36f1('0x19')][_0x36f1('0x18')]);}})[_0x36f1('0x1a')](function(_0x130537){logger['error']('VoiceExtension,\x20%s,\x20%s',_0x477f86,_0x130537);_0x1ec653(_0x130537);});});}exports[_0x36f1('0x1b')]=function(_0x5e7595){var _0x32a028=this;return new Promise(function(_0x20178e,_0x421f15){return db['VoiceExtension'][_0x36f1('0x1c')]({'raw':_0x5e7595[_0x36f1('0x1d')]?_0x5e7595['options'][_0x36f1('0x1e')]===undefined?!![]:![]:!![],'where':_0x5e7595['options']?_0x5e7595['options'][_0x36f1('0x1f')]||null:null,'attributes':_0x5e7595['options']?_0x5e7595[_0x36f1('0x1d')]['attributes']||null:null,'limit':_0x5e7595['options']?_0x5e7595['options'][_0x36f1('0x20')]||null:null,'include':_0x5e7595[_0x36f1('0x1d')]?_0x5e7595[_0x36f1('0x1d')][_0x36f1('0x21')]?_['map'](_0x5e7595[_0x36f1('0x1d')][_0x36f1('0x21')],function(_0x16ec1e){return{'model':db[_0x16ec1e['model']],'as':_0x16ec1e['as'],'attributes':_0x16ec1e[_0x36f1('0x22')],'include':_0x16ec1e[_0x36f1('0x21')]?_[_0x36f1('0x23')](_0x16ec1e[_0x36f1('0x21')],function(_0x5eb4b3){return{'model':db[_0x5eb4b3['model']],'as':_0x5eb4b3['as'],'attributes':_0x5eb4b3[_0x36f1('0x22')],'include':_0x5eb4b3[_0x36f1('0x21')]?_[_0x36f1('0x23')](_0x5eb4b3['include'],function(_0x4a4689){return{'model':db[_0x4a4689[_0x36f1('0x24')]],'as':_0x4a4689['as'],'attributes':_0x4a4689[_0x36f1('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2da9e5){logger['info'](_0x36f1('0x1b'),_0x5e7595);logger[_0x36f1('0x25')](_0x36f1('0x1b'),_0x5e7595,JSON[_0x36f1('0x15')](_0x2da9e5));_0x20178e(_0x2da9e5);})[_0x36f1('0x1a')](function(_0x1df323){logger[_0x36f1('0x16')]('GetVoiceExtension',_0x1df323[_0x36f1('0x18')],_0x5e7595);_0x421f15(_0x32a028['error'](0x1f4,_0x1df323[_0x36f1('0x18')]));});});};