Built motion from commit (unavailable).|2.5.23
[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 _0x1d1b=['map','model','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','socket.io-emitter','register','request','then','request\x20sent','debug','stringify','error','code','VoiceExtension,\x20%s,\x20%s','message','info','catch','GetVoiceExtension','options','raw','where','attributes','include'];(function(_0x5b6792,_0x25e6dd){var _0x584189=function(_0xed202a){while(--_0xed202a){_0x5b6792['push'](_0x5b6792['shift']());}};_0x584189(++_0x25e6dd);}(_0x1d1b,0xac));var _0xb1d1=function(_0x420a64,_0x1aa640){_0x420a64=_0x420a64-0x0;var _0x50648b=_0x1d1b[_0x420a64];return _0x50648b;};'use strict';var _=require('lodash');var util=require(_0xb1d1('0x0'));var moment=require(_0xb1d1('0x1'));var BPromise=require(_0xb1d1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb1d1('0x3'));var db=require(_0xb1d1('0x4'))['db'];var utils=require(_0xb1d1('0x5'));var logger=require(_0xb1d1('0x6'))(_0xb1d1('0x7'));var config=require('../../config/environment');var jayson=require(_0xb1d1('0x8'));var client=jayson[_0xb1d1('0x9')][_0xb1d1('0xa')]({'port':0x232a});config[_0xb1d1('0xb')]=_['defaults'](config[_0xb1d1('0xb')],{'host':_0xb1d1('0xc'),'port':0x18eb});var socket=require(_0xb1d1('0xd'))(new Redis(config[_0xb1d1('0xb')]));require('./voiceExtension.socket')[_0xb1d1('0xe')](socket);function respondWithRpcPromise(_0x3e6ec3,_0x14eb83,_0x2338af){return new BPromise(function(_0xc6582b,_0x4a7142){return client[_0xb1d1('0xf')](_0x3e6ec3,_0x2338af)[_0xb1d1('0x10')](function(_0x53202a){logger['info']('VoiceExtension,\x20%s,\x20%s',_0x14eb83,_0xb1d1('0x11'));logger[_0xb1d1('0x12')]('VoiceExtension,\x20%s,\x20%s,\x20%s',_0x14eb83,_0xb1d1('0x11'),JSON[_0xb1d1('0x13')](_0x53202a));if(_0x53202a[_0xb1d1('0x14')]){if(_0x53202a[_0xb1d1('0x14')][_0xb1d1('0x15')]===0x1f4){logger[_0xb1d1('0x14')](_0xb1d1('0x16'),_0x14eb83,_0x53202a[_0xb1d1('0x14')][_0xb1d1('0x17')]);return _0x4a7142(_0x53202a['error'][_0xb1d1('0x17')]);}logger['error'](_0xb1d1('0x16'),_0x14eb83,_0x53202a[_0xb1d1('0x14')][_0xb1d1('0x17')]);return _0xc6582b(_0x53202a[_0xb1d1('0x14')][_0xb1d1('0x17')]);}else{logger[_0xb1d1('0x18')](_0xb1d1('0x16'),_0x14eb83,'request\x20sent');_0xc6582b(_0x53202a['result'][_0xb1d1('0x17')]);}})[_0xb1d1('0x19')](function(_0x347167){logger[_0xb1d1('0x14')](_0xb1d1('0x16'),_0x14eb83,_0x347167);_0x4a7142(_0x347167);});});}exports[_0xb1d1('0x1a')]=function(_0x13c515){var _0x1d502c=this;return new Promise(function(_0x3ce4b3,_0x5dbc34){return db['VoiceExtension']['findAll']({'raw':_0x13c515[_0xb1d1('0x1b')]?_0x13c515['options'][_0xb1d1('0x1c')]===undefined?!![]:![]:!![],'where':_0x13c515[_0xb1d1('0x1b')]?_0x13c515[_0xb1d1('0x1b')][_0xb1d1('0x1d')]||null:null,'attributes':_0x13c515[_0xb1d1('0x1b')]?_0x13c515[_0xb1d1('0x1b')][_0xb1d1('0x1e')]||null:null,'limit':_0x13c515[_0xb1d1('0x1b')]?_0x13c515[_0xb1d1('0x1b')]['limit']||null:null,'include':_0x13c515[_0xb1d1('0x1b')]?_0x13c515[_0xb1d1('0x1b')][_0xb1d1('0x1f')]?_[_0xb1d1('0x20')](_0x13c515[_0xb1d1('0x1b')][_0xb1d1('0x1f')],function(_0x2a0ad5){return{'model':db[_0x2a0ad5[_0xb1d1('0x21')]],'as':_0x2a0ad5['as'],'attributes':_0x2a0ad5[_0xb1d1('0x1e')],'include':_0x2a0ad5['include']?_[_0xb1d1('0x20')](_0x2a0ad5[_0xb1d1('0x1f')],function(_0x3d962e){return{'model':db[_0x3d962e[_0xb1d1('0x21')]],'as':_0x3d962e['as'],'attributes':_0x3d962e[_0xb1d1('0x1e')],'include':_0x3d962e[_0xb1d1('0x1f')]?_['map'](_0x3d962e['include'],function(_0x11d111){return{'model':db[_0x11d111[_0xb1d1('0x21')]],'as':_0x11d111['as'],'attributes':_0x11d111[_0xb1d1('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb1d1('0x10')](function(_0x1ed74a){logger['info']('GetVoiceExtension',_0x13c515);logger[_0xb1d1('0x12')]('GetVoiceExtension',_0x13c515,JSON[_0xb1d1('0x13')](_0x1ed74a));_0x3ce4b3(_0x1ed74a);})[_0xb1d1('0x19')](function(_0x23476f){logger[_0xb1d1('0x14')]('GetVoiceExtension',_0x23476f[_0xb1d1('0x17')],_0x13c515);_0x5dbc34(_0x1d502c[_0xb1d1('0x14')](0x1f4,_0x23476f[_0xb1d1('0x17')]));});});};