Built motion from commit bab6f49e.|2.6.17
[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 _0x3f8a=['debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceExtension','VoiceExtension','options','raw','where','attributes','limit','include','map','model','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceExtension.socket','register','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent'];(function(_0x41039e,_0x275082){var _0x228c51=function(_0x46a3ad){while(--_0x46a3ad){_0x41039e['push'](_0x41039e['shift']());}};_0x228c51(++_0x275082);}(_0x3f8a,0x1d5));var _0xa3f8=function(_0x52f351,_0x3d1e32){_0x52f351=_0x52f351-0x0;var _0x5c9a62=_0x3f8a[_0x52f351];return _0x5c9a62;};'use strict';var _=require(_0xa3f8('0x0'));var util=require(_0xa3f8('0x1'));var moment=require(_0xa3f8('0x2'));var BPromise=require(_0xa3f8('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa3f8('0x4'));var db=require(_0xa3f8('0x5'))['db'];var utils=require(_0xa3f8('0x6'));var logger=require(_0xa3f8('0x7'))(_0xa3f8('0x8'));var config=require(_0xa3f8('0x9'));var jayson=require(_0xa3f8('0xa'));var client=jayson[_0xa3f8('0xb')][_0xa3f8('0xc')]({'port':0x232a});config[_0xa3f8('0xd')]=_[_0xa3f8('0xe')](config[_0xa3f8('0xd')],{'host':_0xa3f8('0xf'),'port':0x18eb});var socket=require(_0xa3f8('0x10'))(new Redis(config[_0xa3f8('0xd')]));require(_0xa3f8('0x11'))[_0xa3f8('0x12')](socket);function respondWithRpcPromise(_0x5c3288,_0x47496a,_0x13a082){return new BPromise(function(_0x3c1833,_0x22dcda){return client['request'](_0x5c3288,_0x13a082)[_0xa3f8('0x13')](function(_0x26f0a0){logger[_0xa3f8('0x14')](_0xa3f8('0x15'),_0x47496a,_0xa3f8('0x16'));logger[_0xa3f8('0x17')](_0xa3f8('0x18'),_0x47496a,_0xa3f8('0x16'),JSON[_0xa3f8('0x19')](_0x26f0a0));if(_0x26f0a0[_0xa3f8('0x1a')]){if(_0x26f0a0[_0xa3f8('0x1a')][_0xa3f8('0x1b')]===0x1f4){logger['error'](_0xa3f8('0x15'),_0x47496a,_0x26f0a0[_0xa3f8('0x1a')][_0xa3f8('0x1c')]);return _0x22dcda(_0x26f0a0[_0xa3f8('0x1a')]['message']);}logger[_0xa3f8('0x1a')](_0xa3f8('0x15'),_0x47496a,_0x26f0a0[_0xa3f8('0x1a')][_0xa3f8('0x1c')]);return _0x3c1833(_0x26f0a0[_0xa3f8('0x1a')][_0xa3f8('0x1c')]);}else{logger[_0xa3f8('0x14')](_0xa3f8('0x15'),_0x47496a,_0xa3f8('0x16'));_0x3c1833(_0x26f0a0[_0xa3f8('0x1d')]['message']);}})[_0xa3f8('0x1e')](function(_0x5a0e18){logger[_0xa3f8('0x1a')](_0xa3f8('0x15'),_0x47496a,_0x5a0e18);_0x22dcda(_0x5a0e18);});});}exports[_0xa3f8('0x1f')]=function(_0x46042d){var _0x5c916e=this;return new Promise(function(_0x1f0bb8,_0x5b0d57){return db[_0xa3f8('0x20')]['findAll']({'raw':_0x46042d[_0xa3f8('0x21')]?_0x46042d[_0xa3f8('0x21')][_0xa3f8('0x22')]===undefined?!![]:![]:!![],'where':_0x46042d[_0xa3f8('0x21')]?_0x46042d[_0xa3f8('0x21')][_0xa3f8('0x23')]||null:null,'attributes':_0x46042d[_0xa3f8('0x21')]?_0x46042d['options'][_0xa3f8('0x24')]||null:null,'limit':_0x46042d['options']?_0x46042d[_0xa3f8('0x21')][_0xa3f8('0x25')]||null:null,'include':_0x46042d[_0xa3f8('0x21')]?_0x46042d[_0xa3f8('0x21')][_0xa3f8('0x26')]?_[_0xa3f8('0x27')](_0x46042d[_0xa3f8('0x21')][_0xa3f8('0x26')],function(_0x1e22b8){return{'model':db[_0x1e22b8[_0xa3f8('0x28')]],'as':_0x1e22b8['as'],'attributes':_0x1e22b8['attributes'],'include':_0x1e22b8[_0xa3f8('0x26')]?_[_0xa3f8('0x27')](_0x1e22b8[_0xa3f8('0x26')],function(_0x5a8fcf){return{'model':db[_0x5a8fcf[_0xa3f8('0x28')]],'as':_0x5a8fcf['as'],'attributes':_0x5a8fcf['attributes'],'include':_0x5a8fcf[_0xa3f8('0x26')]?_[_0xa3f8('0x27')](_0x5a8fcf[_0xa3f8('0x26')],function(_0x4ea213){return{'model':db[_0x4ea213[_0xa3f8('0x28')]],'as':_0x4ea213['as'],'attributes':_0x4ea213['attributes']};}):[]};}):[]};}):[]:[]})[_0xa3f8('0x13')](function(_0x4281ea){logger[_0xa3f8('0x14')](_0xa3f8('0x1f'),_0x46042d);logger[_0xa3f8('0x17')](_0xa3f8('0x1f'),_0x46042d,JSON[_0xa3f8('0x19')](_0x4281ea));_0x1f0bb8(_0x4281ea);})[_0xa3f8('0x1e')](function(_0x25f9f5){logger[_0xa3f8('0x1a')](_0xa3f8('0x1f'),_0x25f9f5['message'],_0x46042d);_0x5b0d57(_0x5c916e[_0xa3f8('0x1a')](0x1f4,_0x25f9f5[_0xa3f8('0x1c')]));});});};