51021a7ac37516b83d0b00f8513f9c01bc1d0ac1
[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 _0x7665=['map','model','GetVoiceExtension','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','client','http','redis','defaults','localhost','./voiceExtension.socket','register','request','then','info','request\x20sent','debug','stringify','error','VoiceExtension,\x20%s,\x20%s','message','result','options','raw','where','attributes','limit','include'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0x7665,0xa8));var _0x5766=function(_0x942f2f,_0x1b8737){_0x942f2f=_0x942f2f-0x0;var _0x3daa0a=_0x7665[_0x942f2f];return _0x3daa0a;};'use strict';var _=require('lodash');var util=require(_0x5766('0x0'));var moment=require(_0x5766('0x1'));var BPromise=require('bluebird');var rs=require(_0x5766('0x2'));var fs=require('fs');var Redis=require(_0x5766('0x3'));var db=require(_0x5766('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x5766('0x5'))(_0x5766('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x5766('0x7')][_0x5766('0x8')]({'port':0x232a});config[_0x5766('0x9')]=_[_0x5766('0xa')](config[_0x5766('0x9')],{'host':_0x5766('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x5766('0x9')]));require(_0x5766('0xc'))[_0x5766('0xd')](socket);function respondWithRpcPromise(_0x336099,_0x37c8ae,_0x2022ae){return new BPromise(function(_0x1b3f19,_0x479563){return client[_0x5766('0xe')](_0x336099,_0x2022ae)[_0x5766('0xf')](function(_0x540af3){logger[_0x5766('0x10')]('VoiceExtension,\x20%s,\x20%s',_0x37c8ae,_0x5766('0x11'));logger[_0x5766('0x12')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x37c8ae,_0x5766('0x11'),JSON[_0x5766('0x13')](_0x540af3));if(_0x540af3[_0x5766('0x14')]){if(_0x540af3[_0x5766('0x14')]['code']===0x1f4){logger['error'](_0x5766('0x15'),_0x37c8ae,_0x540af3['error']['message']);return _0x479563(_0x540af3[_0x5766('0x14')]['message']);}logger[_0x5766('0x14')]('VoiceExtension,\x20%s,\x20%s',_0x37c8ae,_0x540af3[_0x5766('0x14')]['message']);return _0x1b3f19(_0x540af3[_0x5766('0x14')][_0x5766('0x16')]);}else{logger[_0x5766('0x10')](_0x5766('0x15'),_0x37c8ae,_0x5766('0x11'));_0x1b3f19(_0x540af3[_0x5766('0x17')][_0x5766('0x16')]);}})['catch'](function(_0x3e934a){logger[_0x5766('0x14')](_0x5766('0x15'),_0x37c8ae,_0x3e934a);_0x479563(_0x3e934a);});});}exports['GetVoiceExtension']=function(_0x4a5d96){var _0x246639=this;return new Promise(function(_0x5deeef,_0x4e6752){return db['VoiceExtension']['findAll']({'raw':_0x4a5d96[_0x5766('0x18')]?_0x4a5d96[_0x5766('0x18')][_0x5766('0x19')]===undefined?!![]:![]:!![],'where':_0x4a5d96['options']?_0x4a5d96[_0x5766('0x18')][_0x5766('0x1a')]||null:null,'attributes':_0x4a5d96[_0x5766('0x18')]?_0x4a5d96[_0x5766('0x18')][_0x5766('0x1b')]||null:null,'limit':_0x4a5d96[_0x5766('0x18')]?_0x4a5d96[_0x5766('0x18')][_0x5766('0x1c')]||null:null,'include':_0x4a5d96[_0x5766('0x18')]?_0x4a5d96[_0x5766('0x18')][_0x5766('0x1d')]?_[_0x5766('0x1e')](_0x4a5d96[_0x5766('0x18')][_0x5766('0x1d')],function(_0x2b2b8d){return{'model':db[_0x2b2b8d[_0x5766('0x1f')]],'as':_0x2b2b8d['as'],'attributes':_0x2b2b8d['attributes'],'include':_0x2b2b8d[_0x5766('0x1d')]?_[_0x5766('0x1e')](_0x2b2b8d['include'],function(_0x4cdfc8){return{'model':db[_0x4cdfc8[_0x5766('0x1f')]],'as':_0x4cdfc8['as'],'attributes':_0x4cdfc8[_0x5766('0x1b')],'include':_0x4cdfc8[_0x5766('0x1d')]?_[_0x5766('0x1e')](_0x4cdfc8[_0x5766('0x1d')],function(_0x1f80b5){return{'model':db[_0x1f80b5[_0x5766('0x1f')]],'as':_0x1f80b5['as'],'attributes':_0x1f80b5[_0x5766('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x5766('0xf')](function(_0x5ab5d9){logger[_0x5766('0x10')](_0x5766('0x20'),_0x4a5d96);logger['debug']('GetVoiceExtension',_0x4a5d96,JSON['stringify'](_0x5ab5d9));_0x5deeef(_0x5ab5d9);})['catch'](function(_0x1c12ab){logger[_0x5766('0x14')](_0x5766('0x20'),_0x1c12ab['message'],_0x4a5d96);_0x4e6752(_0x246639[_0x5766('0x14')](0x1f4,_0x1c12ab['message']));});});};