Built motion from commit 87cd5f02.|2.5.48
[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 _0x8f6b=['then','info','VoiceExtension,\x20%s,\x20%s','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','catch','GetVoiceExtension','VoiceExtension','options','raw','where','limit','include','map','model','attributes','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','redis','localhost','./voiceExtension.socket','register','request'];(function(_0x273c39,_0x1052e6){var _0x46d6b5=function(_0x44f1fb){while(--_0x44f1fb){_0x273c39['push'](_0x273c39['shift']());}};_0x46d6b5(++_0x1052e6);}(_0x8f6b,0x146));var _0xb8f6=function(_0x3635ce,_0x33a6f9){_0x3635ce=_0x3635ce-0x0;var _0x97ecd0=_0x8f6b[_0x3635ce];return _0x97ecd0;};'use strict';var _=require(_0xb8f6('0x0'));var util=require(_0xb8f6('0x1'));var moment=require(_0xb8f6('0x2'));var BPromise=require('bluebird');var rs=require(_0xb8f6('0x3'));var fs=require('fs');var Redis=require(_0xb8f6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xb8f6('0x5'));var logger=require(_0xb8f6('0x6'))('rpc');var config=require(_0xb8f6('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xb8f6('0x8')]['http']({'port':0x232a});config[_0xb8f6('0x9')]=_['defaults'](config[_0xb8f6('0x9')],{'host':_0xb8f6('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xb8f6('0xb'))[_0xb8f6('0xc')](socket);function respondWithRpcPromise(_0x14cc71,_0x379ed5,_0x165d17){return new BPromise(function(_0x3f8e2a,_0x210f71){return client[_0xb8f6('0xd')](_0x14cc71,_0x165d17)[_0xb8f6('0xe')](function(_0x2ef5c1){logger[_0xb8f6('0xf')](_0xb8f6('0x10'),_0x379ed5,'request\x20sent');logger[_0xb8f6('0x11')](_0xb8f6('0x12'),_0x379ed5,'request\x20sent',JSON[_0xb8f6('0x13')](_0x2ef5c1));if(_0x2ef5c1[_0xb8f6('0x14')]){if(_0x2ef5c1[_0xb8f6('0x14')]['code']===0x1f4){logger[_0xb8f6('0x14')]('VoiceExtension,\x20%s,\x20%s',_0x379ed5,_0x2ef5c1[_0xb8f6('0x14')][_0xb8f6('0x15')]);return _0x210f71(_0x2ef5c1['error']['message']);}logger[_0xb8f6('0x14')](_0xb8f6('0x10'),_0x379ed5,_0x2ef5c1[_0xb8f6('0x14')][_0xb8f6('0x15')]);return _0x3f8e2a(_0x2ef5c1[_0xb8f6('0x14')][_0xb8f6('0x15')]);}else{logger[_0xb8f6('0xf')](_0xb8f6('0x10'),_0x379ed5,_0xb8f6('0x16'));_0x3f8e2a(_0x2ef5c1['result']['message']);}})[_0xb8f6('0x17')](function(_0x4566c5){logger[_0xb8f6('0x14')](_0xb8f6('0x10'),_0x379ed5,_0x4566c5);_0x210f71(_0x4566c5);});});}exports[_0xb8f6('0x18')]=function(_0x5c2506){var _0x113cf8=this;return new Promise(function(_0x13f964,_0x44e6a8){return db[_0xb8f6('0x19')]['findAll']({'raw':_0x5c2506[_0xb8f6('0x1a')]?_0x5c2506[_0xb8f6('0x1a')][_0xb8f6('0x1b')]===undefined?!![]:![]:!![],'where':_0x5c2506[_0xb8f6('0x1a')]?_0x5c2506[_0xb8f6('0x1a')][_0xb8f6('0x1c')]||null:null,'attributes':_0x5c2506[_0xb8f6('0x1a')]?_0x5c2506[_0xb8f6('0x1a')]['attributes']||null:null,'limit':_0x5c2506[_0xb8f6('0x1a')]?_0x5c2506[_0xb8f6('0x1a')][_0xb8f6('0x1d')]||null:null,'include':_0x5c2506[_0xb8f6('0x1a')]?_0x5c2506['options'][_0xb8f6('0x1e')]?_[_0xb8f6('0x1f')](_0x5c2506['options'][_0xb8f6('0x1e')],function(_0x4ee750){return{'model':db[_0x4ee750[_0xb8f6('0x20')]],'as':_0x4ee750['as'],'attributes':_0x4ee750[_0xb8f6('0x21')],'include':_0x4ee750[_0xb8f6('0x1e')]?_[_0xb8f6('0x1f')](_0x4ee750['include'],function(_0x36ad7a){return{'model':db[_0x36ad7a[_0xb8f6('0x20')]],'as':_0x36ad7a['as'],'attributes':_0x36ad7a[_0xb8f6('0x21')],'include':_0x36ad7a['include']?_[_0xb8f6('0x1f')](_0x36ad7a[_0xb8f6('0x1e')],function(_0x2c47e7){return{'model':db[_0x2c47e7[_0xb8f6('0x20')]],'as':_0x2c47e7['as'],'attributes':_0x2c47e7[_0xb8f6('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5d2895){logger[_0xb8f6('0xf')]('GetVoiceExtension',_0x5c2506);logger[_0xb8f6('0x11')]('GetVoiceExtension',_0x5c2506,JSON[_0xb8f6('0x13')](_0x5d2895));_0x13f964(_0x5d2895);})[_0xb8f6('0x17')](function(_0xb1f317){logger[_0xb8f6('0x14')](_0xb8f6('0x18'),_0xb1f317[_0xb8f6('0x15')],_0x5c2506);_0x44e6a8(_0x113cf8[_0xb8f6('0x14')](0x1f4,_0xb1f317[_0xb8f6('0x15')]));});});};