66e6231039fa7e84b91fc798041814cf496f8e0a
[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 _0xfb82=['map','model','catch','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./voiceExtension.socket','register','request','then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','GetVoiceExtension','VoiceExtension','findAll','options','raw','attributes','include'];(function(_0x46e79b,_0x51f63f){var _0x32647d=function(_0x406a58){while(--_0x406a58){_0x46e79b['push'](_0x46e79b['shift']());}};_0x32647d(++_0x51f63f);}(_0xfb82,0x17f));var _0x2fb8=function(_0x524a74,_0x422573){_0x524a74=_0x524a74-0x0;var _0x4bd1c1=_0xfb82[_0x524a74];return _0x4bd1c1;};'use strict';var _=require(_0x2fb8('0x0'));var util=require(_0x2fb8('0x1'));var moment=require(_0x2fb8('0x2'));var BPromise=require('bluebird');var rs=require(_0x2fb8('0x3'));var fs=require('fs');var Redis=require(_0x2fb8('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x2fb8('0x5'));var logger=require(_0x2fb8('0x6'))(_0x2fb8('0x7'));var config=require(_0x2fb8('0x8'));var jayson=require(_0x2fb8('0x9'));var client=jayson[_0x2fb8('0xa')][_0x2fb8('0xb')]({'port':0x232a});config[_0x2fb8('0xc')]=_[_0x2fb8('0xd')](config[_0x2fb8('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x2fb8('0xe'))(new Redis(config[_0x2fb8('0xc')]));require(_0x2fb8('0xf'))[_0x2fb8('0x10')](socket);function respondWithRpcPromise(_0x3f1637,_0x22824a,_0x207a10){return new BPromise(function(_0x2928ef,_0x154d92){return client[_0x2fb8('0x11')](_0x3f1637,_0x207a10)[_0x2fb8('0x12')](function(_0x55bcfc){logger[_0x2fb8('0x13')](_0x2fb8('0x14'),_0x22824a,_0x2fb8('0x15'));logger[_0x2fb8('0x16')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x22824a,'request\x20sent',JSON[_0x2fb8('0x17')](_0x55bcfc));if(_0x55bcfc['error']){if(_0x55bcfc[_0x2fb8('0x18')][_0x2fb8('0x19')]===0x1f4){logger['error'](_0x2fb8('0x14'),_0x22824a,_0x55bcfc[_0x2fb8('0x18')]['message']);return _0x154d92(_0x55bcfc['error'][_0x2fb8('0x1a')]);}logger[_0x2fb8('0x18')](_0x2fb8('0x14'),_0x22824a,_0x55bcfc[_0x2fb8('0x18')]['message']);return _0x2928ef(_0x55bcfc[_0x2fb8('0x18')][_0x2fb8('0x1a')]);}else{logger['info'](_0x2fb8('0x14'),_0x22824a,_0x2fb8('0x15'));_0x2928ef(_0x55bcfc[_0x2fb8('0x1b')]['message']);}})['catch'](function(_0x1bee80){logger[_0x2fb8('0x18')](_0x2fb8('0x14'),_0x22824a,_0x1bee80);_0x154d92(_0x1bee80);});});}exports[_0x2fb8('0x1c')]=function(_0x49396f){var _0x3327f3=this;return new Promise(function(_0xffd9ec,_0x1aa17e){return db[_0x2fb8('0x1d')][_0x2fb8('0x1e')]({'raw':_0x49396f['options']?_0x49396f[_0x2fb8('0x1f')][_0x2fb8('0x20')]===undefined?!![]:![]:!![],'where':_0x49396f[_0x2fb8('0x1f')]?_0x49396f['options']['where']||null:null,'attributes':_0x49396f[_0x2fb8('0x1f')]?_0x49396f[_0x2fb8('0x1f')][_0x2fb8('0x21')]||null:null,'limit':_0x49396f[_0x2fb8('0x1f')]?_0x49396f[_0x2fb8('0x1f')]['limit']||null:null,'include':_0x49396f[_0x2fb8('0x1f')]?_0x49396f[_0x2fb8('0x1f')][_0x2fb8('0x22')]?_[_0x2fb8('0x23')](_0x49396f[_0x2fb8('0x1f')][_0x2fb8('0x22')],function(_0x2babf4){return{'model':db[_0x2babf4['model']],'as':_0x2babf4['as'],'attributes':_0x2babf4[_0x2fb8('0x21')],'include':_0x2babf4['include']?_[_0x2fb8('0x23')](_0x2babf4[_0x2fb8('0x22')],function(_0x77bdc2){return{'model':db[_0x77bdc2[_0x2fb8('0x24')]],'as':_0x77bdc2['as'],'attributes':_0x77bdc2[_0x2fb8('0x21')],'include':_0x77bdc2[_0x2fb8('0x22')]?_[_0x2fb8('0x23')](_0x77bdc2[_0x2fb8('0x22')],function(_0x4f9adf){return{'model':db[_0x4f9adf[_0x2fb8('0x24')]],'as':_0x4f9adf['as'],'attributes':_0x4f9adf[_0x2fb8('0x21')]};}):[]};}):[]};}):[]:[]})[_0x2fb8('0x12')](function(_0x462937){logger[_0x2fb8('0x13')](_0x2fb8('0x1c'),_0x49396f);logger[_0x2fb8('0x16')]('GetVoiceExtension',_0x49396f,JSON['stringify'](_0x462937));_0xffd9ec(_0x462937);})[_0x2fb8('0x25')](function(_0x148418){logger['error']('GetVoiceExtension',_0x148418[_0x2fb8('0x1a')],_0x49396f);_0x1aa17e(_0x3327f3['error'](0x1f4,_0x148418['message']));});});};