Built motion from commit (unavailable).|2.5.4
[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 _0xbf12=['register','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceExtension','VoiceExtension','options','where','attributes','limit','include','map','model','then','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceExtension.socket'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xbf12,0x8b));var _0x2bf1=function(_0x52bbc9,_0x3524f0){_0x52bbc9=_0x52bbc9-0x0;var _0x26e579=_0xbf12[_0x52bbc9];return _0x26e579;};'use strict';var _=require(_0x2bf1('0x0'));var util=require('util');var moment=require(_0x2bf1('0x1'));var BPromise=require(_0x2bf1('0x2'));var rs=require(_0x2bf1('0x3'));var fs=require('fs');var Redis=require(_0x2bf1('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x2bf1('0x5'));var logger=require(_0x2bf1('0x6'))(_0x2bf1('0x7'));var config=require(_0x2bf1('0x8'));var jayson=require(_0x2bf1('0x9'));var client=jayson[_0x2bf1('0xa')][_0x2bf1('0xb')]({'port':0x232a});config[_0x2bf1('0xc')]=_[_0x2bf1('0xd')](config[_0x2bf1('0xc')],{'host':_0x2bf1('0xe'),'port':0x18eb});var socket=require(_0x2bf1('0xf'))(new Redis(config[_0x2bf1('0xc')]));require(_0x2bf1('0x10'))[_0x2bf1('0x11')](socket);function respondWithRpcPromise(_0x150312,_0x428531,_0x33e36b){return new BPromise(function(_0x13ee85,_0x20ed15){return client['request'](_0x150312,_0x33e36b)['then'](function(_0x404664){logger[_0x2bf1('0x12')](_0x2bf1('0x13'),_0x428531,_0x2bf1('0x14'));logger[_0x2bf1('0x15')](_0x2bf1('0x16'),_0x428531,_0x2bf1('0x14'),JSON[_0x2bf1('0x17')](_0x404664));if(_0x404664[_0x2bf1('0x18')]){if(_0x404664['error'][_0x2bf1('0x19')]===0x1f4){logger[_0x2bf1('0x18')](_0x2bf1('0x13'),_0x428531,_0x404664['error'][_0x2bf1('0x1a')]);return _0x20ed15(_0x404664['error'][_0x2bf1('0x1a')]);}logger[_0x2bf1('0x18')](_0x2bf1('0x13'),_0x428531,_0x404664['error'][_0x2bf1('0x1a')]);return _0x13ee85(_0x404664[_0x2bf1('0x18')]['message']);}else{logger['info'](_0x2bf1('0x13'),_0x428531,_0x2bf1('0x14'));_0x13ee85(_0x404664[_0x2bf1('0x1b')]['message']);}})[_0x2bf1('0x1c')](function(_0x363d75){logger[_0x2bf1('0x18')]('VoiceExtension,\x20%s,\x20%s',_0x428531,_0x363d75);_0x20ed15(_0x363d75);});});}exports[_0x2bf1('0x1d')]=function(_0x1284ef){var _0x1678b0=this;return new Promise(function(_0x5eeb9e,_0x4be86d){return db[_0x2bf1('0x1e')]['findAll']({'raw':_0x1284ef['options']?_0x1284ef[_0x2bf1('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x1284ef[_0x2bf1('0x1f')]?_0x1284ef['options'][_0x2bf1('0x20')]||null:null,'attributes':_0x1284ef[_0x2bf1('0x1f')]?_0x1284ef[_0x2bf1('0x1f')][_0x2bf1('0x21')]||null:null,'limit':_0x1284ef[_0x2bf1('0x1f')]?_0x1284ef[_0x2bf1('0x1f')][_0x2bf1('0x22')]||null:null,'include':_0x1284ef[_0x2bf1('0x1f')]?_0x1284ef[_0x2bf1('0x1f')][_0x2bf1('0x23')]?_[_0x2bf1('0x24')](_0x1284ef['options'][_0x2bf1('0x23')],function(_0xdf8837){return{'model':db[_0xdf8837[_0x2bf1('0x25')]],'as':_0xdf8837['as'],'attributes':_0xdf8837[_0x2bf1('0x21')],'include':_0xdf8837['include']?_[_0x2bf1('0x24')](_0xdf8837[_0x2bf1('0x23')],function(_0x493c00){return{'model':db[_0x493c00[_0x2bf1('0x25')]],'as':_0x493c00['as'],'attributes':_0x493c00[_0x2bf1('0x21')],'include':_0x493c00[_0x2bf1('0x23')]?_[_0x2bf1('0x24')](_0x493c00[_0x2bf1('0x23')],function(_0x29fae7){return{'model':db[_0x29fae7[_0x2bf1('0x25')]],'as':_0x29fae7['as'],'attributes':_0x29fae7[_0x2bf1('0x21')]};}):[]};}):[]};}):[]:[]})[_0x2bf1('0x26')](function(_0x281fe7){logger[_0x2bf1('0x12')](_0x2bf1('0x1d'),_0x1284ef);logger[_0x2bf1('0x15')](_0x2bf1('0x1d'),_0x1284ef,JSON['stringify'](_0x281fe7));_0x5eeb9e(_0x281fe7);})[_0x2bf1('0x1c')](function(_0x1dc5b0){logger['error']('GetVoiceExtension',_0x1dc5b0[_0x2bf1('0x1a')],_0x1284ef);_0x4be86d(_0x1678b0[_0x2bf1('0x18')](0x1f4,_0x1dc5b0[_0x2bf1('0x1a')]));});});};