Built motion from commit f7863d46.|2.5.41
[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 _0x0e76=['client','http','redis','defaults','socket.io-emitter','./voiceExtension.socket','request','info','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','VoiceExtension,\x20%s,\x20%s','message','result','catch','GetVoiceExtension','VoiceExtension','options','where','attributes','include','model','map','then','lodash','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x648163,_0x241576){var _0x199d4d=function(_0x23055d){while(--_0x23055d){_0x648163['push'](_0x648163['shift']());}};_0x199d4d(++_0x241576);}(_0x0e76,0xc4));var _0x60e7=function(_0x1beef3,_0x57c4b8){_0x1beef3=_0x1beef3-0x0;var _0x5af964=_0x0e76[_0x1beef3];return _0x5af964;};'use strict';var _=require(_0x60e7('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x60e7('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x60e7('0x2'));var db=require(_0x60e7('0x3'))['db'];var utils=require(_0x60e7('0x4'));var logger=require(_0x60e7('0x5'))(_0x60e7('0x6'));var config=require('../../config/environment');var jayson=require(_0x60e7('0x7'));var client=jayson[_0x60e7('0x8')][_0x60e7('0x9')]({'port':0x232a});config[_0x60e7('0xa')]=_[_0x60e7('0xb')](config[_0x60e7('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x60e7('0xc'))(new Redis(config[_0x60e7('0xa')]));require(_0x60e7('0xd'))['register'](socket);function respondWithRpcPromise(_0x5c442d,_0x498fab,_0x14d531){return new BPromise(function(_0x25d13b,_0x54ca7f){return client[_0x60e7('0xe')](_0x5c442d,_0x14d531)['then'](function(_0x304841){logger[_0x60e7('0xf')]('VoiceExtension,\x20%s,\x20%s',_0x498fab,'request\x20sent');logger[_0x60e7('0x10')](_0x60e7('0x11'),_0x498fab,_0x60e7('0x12'),JSON[_0x60e7('0x13')](_0x304841));if(_0x304841['error']){if(_0x304841[_0x60e7('0x14')]['code']===0x1f4){logger[_0x60e7('0x14')](_0x60e7('0x15'),_0x498fab,_0x304841['error'][_0x60e7('0x16')]);return _0x54ca7f(_0x304841['error'][_0x60e7('0x16')]);}logger[_0x60e7('0x14')](_0x60e7('0x15'),_0x498fab,_0x304841['error']['message']);return _0x25d13b(_0x304841[_0x60e7('0x14')]['message']);}else{logger[_0x60e7('0xf')](_0x60e7('0x15'),_0x498fab,_0x60e7('0x12'));_0x25d13b(_0x304841[_0x60e7('0x17')]['message']);}})[_0x60e7('0x18')](function(_0x4fd306){logger[_0x60e7('0x14')](_0x60e7('0x15'),_0x498fab,_0x4fd306);_0x54ca7f(_0x4fd306);});});}exports[_0x60e7('0x19')]=function(_0xeaaafc){var _0x200ac7=this;return new Promise(function(_0x184727,_0x2c602d){return db[_0x60e7('0x1a')]['findAll']({'raw':_0xeaaafc[_0x60e7('0x1b')]?_0xeaaafc[_0x60e7('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0xeaaafc[_0x60e7('0x1b')]?_0xeaaafc['options'][_0x60e7('0x1c')]||null:null,'attributes':_0xeaaafc[_0x60e7('0x1b')]?_0xeaaafc[_0x60e7('0x1b')][_0x60e7('0x1d')]||null:null,'limit':_0xeaaafc[_0x60e7('0x1b')]?_0xeaaafc[_0x60e7('0x1b')]['limit']||null:null,'include':_0xeaaafc[_0x60e7('0x1b')]?_0xeaaafc[_0x60e7('0x1b')][_0x60e7('0x1e')]?_['map'](_0xeaaafc['options'][_0x60e7('0x1e')],function(_0x34da5e){return{'model':db[_0x34da5e[_0x60e7('0x1f')]],'as':_0x34da5e['as'],'attributes':_0x34da5e[_0x60e7('0x1d')],'include':_0x34da5e['include']?_[_0x60e7('0x20')](_0x34da5e[_0x60e7('0x1e')],function(_0x39a0a9){return{'model':db[_0x39a0a9[_0x60e7('0x1f')]],'as':_0x39a0a9['as'],'attributes':_0x39a0a9[_0x60e7('0x1d')],'include':_0x39a0a9['include']?_[_0x60e7('0x20')](_0x39a0a9[_0x60e7('0x1e')],function(_0x24896b){return{'model':db[_0x24896b[_0x60e7('0x1f')]],'as':_0x24896b['as'],'attributes':_0x24896b[_0x60e7('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x60e7('0x21')](function(_0x532ab2){logger[_0x60e7('0xf')]('GetVoiceExtension',_0xeaaafc);logger[_0x60e7('0x10')]('GetVoiceExtension',_0xeaaafc,JSON[_0x60e7('0x13')](_0x532ab2));_0x184727(_0x532ab2);})[_0x60e7('0x18')](function(_0x3f3d5d){logger[_0x60e7('0x14')](_0x60e7('0x19'),_0x3f3d5d[_0x60e7('0x16')],_0xeaaafc);_0x2c602d(_0x200ac7[_0x60e7('0x14')](0x1f4,_0x3f3d5d['message']));});});};