Built motion from commit (unavailable).|2.5.26
[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 _0x4c6c=['jayson/promise','client','http','redis','defaults','./voiceExtension.socket','request','then','VoiceExtension,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','GetVoiceExtension','VoiceExtension','findAll','options','raw','where','attributes','include','map','model','debug','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment'];(function(_0x2e8a6e,_0x18e64f){var _0x259829=function(_0x230dac){while(--_0x230dac){_0x2e8a6e['push'](_0x2e8a6e['shift']());}};_0x259829(++_0x18e64f);}(_0x4c6c,0x100));var _0xc4c6=function(_0x450b03,_0x16b6e2){_0x450b03=_0x450b03-0x0;var _0x16267b=_0x4c6c[_0x450b03];return _0x16267b;};'use strict';var _=require(_0xc4c6('0x0'));var util=require(_0xc4c6('0x1'));var moment=require(_0xc4c6('0x2'));var BPromise=require(_0xc4c6('0x3'));var rs=require(_0xc4c6('0x4'));var fs=require('fs');var Redis=require(_0xc4c6('0x5'));var db=require(_0xc4c6('0x6'))['db'];var utils=require(_0xc4c6('0x7'));var logger=require('../../config/logger')(_0xc4c6('0x8'));var config=require(_0xc4c6('0x9'));var jayson=require(_0xc4c6('0xa'));var client=jayson[_0xc4c6('0xb')][_0xc4c6('0xc')]({'port':0x232a});config[_0xc4c6('0xd')]=_[_0xc4c6('0xe')](config[_0xc4c6('0xd')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc4c6('0xd')]));require(_0xc4c6('0xf'))['register'](socket);function respondWithRpcPromise(_0x31c33e,_0x301d1c,_0x28a100){return new BPromise(function(_0x29aee5,_0x1f26a7){return client[_0xc4c6('0x10')](_0x31c33e,_0x28a100)[_0xc4c6('0x11')](function(_0x15b343){logger['info'](_0xc4c6('0x12'),_0x301d1c,'request\x20sent');logger['debug']('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x301d1c,_0xc4c6('0x13'),JSON[_0xc4c6('0x14')](_0x15b343));if(_0x15b343['error']){if(_0x15b343[_0xc4c6('0x15')][_0xc4c6('0x16')]===0x1f4){logger[_0xc4c6('0x15')](_0xc4c6('0x12'),_0x301d1c,_0x15b343[_0xc4c6('0x15')][_0xc4c6('0x17')]);return _0x1f26a7(_0x15b343[_0xc4c6('0x15')][_0xc4c6('0x17')]);}logger['error'](_0xc4c6('0x12'),_0x301d1c,_0x15b343[_0xc4c6('0x15')][_0xc4c6('0x17')]);return _0x29aee5(_0x15b343[_0xc4c6('0x15')][_0xc4c6('0x17')]);}else{logger[_0xc4c6('0x18')](_0xc4c6('0x12'),_0x301d1c,'request\x20sent');_0x29aee5(_0x15b343[_0xc4c6('0x19')][_0xc4c6('0x17')]);}})['catch'](function(_0x499059){logger[_0xc4c6('0x15')]('VoiceExtension,\x20%s,\x20%s',_0x301d1c,_0x499059);_0x1f26a7(_0x499059);});});}exports[_0xc4c6('0x1a')]=function(_0x3c37b0){var _0x3b245e=this;return new Promise(function(_0x4b271b,_0x1a0c0e){return db[_0xc4c6('0x1b')][_0xc4c6('0x1c')]({'raw':_0x3c37b0[_0xc4c6('0x1d')]?_0x3c37b0['options'][_0xc4c6('0x1e')]===undefined?!![]:![]:!![],'where':_0x3c37b0[_0xc4c6('0x1d')]?_0x3c37b0['options'][_0xc4c6('0x1f')]||null:null,'attributes':_0x3c37b0[_0xc4c6('0x1d')]?_0x3c37b0['options'][_0xc4c6('0x20')]||null:null,'limit':_0x3c37b0['options']?_0x3c37b0[_0xc4c6('0x1d')]['limit']||null:null,'include':_0x3c37b0[_0xc4c6('0x1d')]?_0x3c37b0[_0xc4c6('0x1d')][_0xc4c6('0x21')]?_[_0xc4c6('0x22')](_0x3c37b0['options'][_0xc4c6('0x21')],function(_0x55e520){return{'model':db[_0x55e520[_0xc4c6('0x23')]],'as':_0x55e520['as'],'attributes':_0x55e520['attributes'],'include':_0x55e520[_0xc4c6('0x21')]?_['map'](_0x55e520['include'],function(_0x12681a){return{'model':db[_0x12681a[_0xc4c6('0x23')]],'as':_0x12681a['as'],'attributes':_0x12681a[_0xc4c6('0x20')],'include':_0x12681a['include']?_['map'](_0x12681a['include'],function(_0x821d7){return{'model':db[_0x821d7[_0xc4c6('0x23')]],'as':_0x821d7['as'],'attributes':_0x821d7[_0xc4c6('0x20')]};}):[]};}):[]};}):[]:[]})[_0xc4c6('0x11')](function(_0x7dc0eb){logger[_0xc4c6('0x18')]('GetVoiceExtension',_0x3c37b0);logger[_0xc4c6('0x24')](_0xc4c6('0x1a'),_0x3c37b0,JSON[_0xc4c6('0x14')](_0x7dc0eb));_0x4b271b(_0x7dc0eb);})[_0xc4c6('0x25')](function(_0x81fd67){logger[_0xc4c6('0x15')]('GetVoiceExtension',_0x81fd67[_0xc4c6('0x17')],_0x3c37b0);_0x1a0c0e(_0x3b245e[_0xc4c6('0x15')](0x1f4,_0x81fd67['message']));});});};