Built motion from commit (unavailable).|2.5.2
[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 _0x2565=['socket.io-emitter','./voiceExtension.socket','register','request','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','message','result','VoiceExtension','findAll','options','raw','limit','include','model','map','attributes','then','GetVoiceExtension','debug','catch','moment','bluebird','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost'];(function(_0x3480e9,_0x1ce980){var _0x389aad=function(_0x4b6bda){while(--_0x4b6bda){_0x3480e9['push'](_0x3480e9['shift']());}};_0x389aad(++_0x1ce980);}(_0x2565,0x15d));var _0x5256=function(_0x172aec,_0x53cc81){_0x172aec=_0x172aec-0x0;var _0x569cdc=_0x2565[_0x172aec];return _0x569cdc;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x5256('0x0'));var BPromise=require(_0x5256('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x5256('0x2'))(_0x5256('0x3'));var config=require(_0x5256('0x4'));var jayson=require(_0x5256('0x5'));var client=jayson[_0x5256('0x6')][_0x5256('0x7')]({'port':0x232a});config[_0x5256('0x8')]=_[_0x5256('0x9')](config[_0x5256('0x8')],{'host':_0x5256('0xa'),'port':0x18eb});var socket=require(_0x5256('0xb'))(new Redis(config[_0x5256('0x8')]));require(_0x5256('0xc'))[_0x5256('0xd')](socket);function respondWithRpcPromise(_0x5c9c04,_0x58a2fc,_0x345d67){return new BPromise(function(_0x5f1122,_0x178266){return client[_0x5256('0xe')](_0x5c9c04,_0x345d67)['then'](function(_0x3e30c5){logger[_0x5256('0xf')](_0x5256('0x10'),_0x58a2fc,_0x5256('0x11'));logger['debug'](_0x5256('0x12'),_0x58a2fc,_0x5256('0x11'),JSON[_0x5256('0x13')](_0x3e30c5));if(_0x3e30c5[_0x5256('0x14')]){if(_0x3e30c5[_0x5256('0x14')]['code']===0x1f4){logger[_0x5256('0x14')](_0x5256('0x10'),_0x58a2fc,_0x3e30c5[_0x5256('0x14')][_0x5256('0x15')]);return _0x178266(_0x3e30c5[_0x5256('0x14')]['message']);}logger[_0x5256('0x14')]('VoiceExtension,\x20%s,\x20%s',_0x58a2fc,_0x3e30c5[_0x5256('0x14')][_0x5256('0x15')]);return _0x5f1122(_0x3e30c5[_0x5256('0x14')][_0x5256('0x15')]);}else{logger[_0x5256('0xf')](_0x5256('0x10'),_0x58a2fc,_0x5256('0x11'));_0x5f1122(_0x3e30c5[_0x5256('0x16')]['message']);}})['catch'](function(_0x5d972f){logger[_0x5256('0x14')]('VoiceExtension,\x20%s,\x20%s',_0x58a2fc,_0x5d972f);_0x178266(_0x5d972f);});});}exports['GetVoiceExtension']=function(_0x1846b9){var _0x15e0cc=this;return new Promise(function(_0x4084c9,_0x376c23){return db[_0x5256('0x17')][_0x5256('0x18')]({'raw':_0x1846b9[_0x5256('0x19')]?_0x1846b9['options'][_0x5256('0x1a')]===undefined?!![]:![]:!![],'where':_0x1846b9['options']?_0x1846b9[_0x5256('0x19')]['where']||null:null,'attributes':_0x1846b9[_0x5256('0x19')]?_0x1846b9[_0x5256('0x19')]['attributes']||null:null,'limit':_0x1846b9['options']?_0x1846b9[_0x5256('0x19')][_0x5256('0x1b')]||null:null,'include':_0x1846b9['options']?_0x1846b9[_0x5256('0x19')][_0x5256('0x1c')]?_['map'](_0x1846b9[_0x5256('0x19')][_0x5256('0x1c')],function(_0x42165c){return{'model':db[_0x42165c[_0x5256('0x1d')]],'as':_0x42165c['as'],'attributes':_0x42165c['attributes'],'include':_0x42165c['include']?_[_0x5256('0x1e')](_0x42165c['include'],function(_0x5ef6af){return{'model':db[_0x5ef6af[_0x5256('0x1d')]],'as':_0x5ef6af['as'],'attributes':_0x5ef6af[_0x5256('0x1f')],'include':_0x5ef6af['include']?_[_0x5256('0x1e')](_0x5ef6af[_0x5256('0x1c')],function(_0x15ccc7){return{'model':db[_0x15ccc7[_0x5256('0x1d')]],'as':_0x15ccc7['as'],'attributes':_0x15ccc7[_0x5256('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x5256('0x20')](function(_0x1867cf){logger[_0x5256('0xf')](_0x5256('0x21'),_0x1846b9);logger[_0x5256('0x22')](_0x5256('0x21'),_0x1846b9,JSON[_0x5256('0x13')](_0x1867cf));_0x4084c9(_0x1867cf);})[_0x5256('0x23')](function(_0x3e0883){logger['error'](_0x5256('0x21'),_0x3e0883['message'],_0x1846b9);_0x376c23(_0x15e0cc[_0x5256('0x14')](0x1f4,_0x3e0883[_0x5256('0x15')]));});});};