f94e763f8ac72f61bbd35462d7579ad84a3eff4a
[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 _0xc92f=['then','info','VoiceExtension,\x20%s,\x20%s','request\x20sent','debug','VoiceExtension,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','GetVoiceExtension','VoiceExtension','findAll','options','raw','attributes','include','map','model','lodash','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','client','redis','socket.io-emitter','./voiceExtension.socket','request'];(function(_0x5c8d8d,_0x33897a){var _0x15237f=function(_0x46b3a8){while(--_0x46b3a8){_0x5c8d8d['push'](_0x5c8d8d['shift']());}};_0x15237f(++_0x33897a);}(_0xc92f,0xf3));var _0xfc92=function(_0x2f5a41,_0x18eb0b){_0x2f5a41=_0x2f5a41-0x0;var _0x13db57=_0xc92f[_0x2f5a41];return _0x13db57;};'use strict';var _=require(_0xfc92('0x0'));var util=require(_0xfc92('0x1'));var moment=require('moment');var BPromise=require(_0xfc92('0x2'));var rs=require(_0xfc92('0x3'));var fs=require('fs');var Redis=require(_0xfc92('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xfc92('0x5'));var logger=require(_0xfc92('0x6'))(_0xfc92('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xfc92('0x8')]['http']({'port':0x232a});config[_0xfc92('0x9')]=_['defaults'](config[_0xfc92('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0xfc92('0xa'))(new Redis(config[_0xfc92('0x9')]));require(_0xfc92('0xb'))['register'](socket);function respondWithRpcPromise(_0x18a53b,_0x379756,_0x213ed0){return new BPromise(function(_0x552eab,_0x66d993){return client[_0xfc92('0xc')](_0x18a53b,_0x213ed0)[_0xfc92('0xd')](function(_0x5dee97){logger[_0xfc92('0xe')](_0xfc92('0xf'),_0x379756,_0xfc92('0x10'));logger[_0xfc92('0x11')](_0xfc92('0x12'),_0x379756,_0xfc92('0x10'),JSON[_0xfc92('0x13')](_0x5dee97));if(_0x5dee97[_0xfc92('0x14')]){if(_0x5dee97['error']['code']===0x1f4){logger['error'](_0xfc92('0xf'),_0x379756,_0x5dee97[_0xfc92('0x14')]['message']);return _0x66d993(_0x5dee97[_0xfc92('0x14')][_0xfc92('0x15')]);}logger[_0xfc92('0x14')](_0xfc92('0xf'),_0x379756,_0x5dee97[_0xfc92('0x14')][_0xfc92('0x15')]);return _0x552eab(_0x5dee97['error'][_0xfc92('0x15')]);}else{logger[_0xfc92('0xe')](_0xfc92('0xf'),_0x379756,_0xfc92('0x10'));_0x552eab(_0x5dee97['result']['message']);}})[_0xfc92('0x16')](function(_0x328345){logger['error'](_0xfc92('0xf'),_0x379756,_0x328345);_0x66d993(_0x328345);});});}exports[_0xfc92('0x17')]=function(_0x597ea2){var _0x1f0b90=this;return new Promise(function(_0x5ec474,_0x376551){return db[_0xfc92('0x18')][_0xfc92('0x19')]({'raw':_0x597ea2[_0xfc92('0x1a')]?_0x597ea2[_0xfc92('0x1a')][_0xfc92('0x1b')]===undefined?!![]:![]:!![],'where':_0x597ea2['options']?_0x597ea2[_0xfc92('0x1a')]['where']||null:null,'attributes':_0x597ea2[_0xfc92('0x1a')]?_0x597ea2[_0xfc92('0x1a')][_0xfc92('0x1c')]||null:null,'limit':_0x597ea2['options']?_0x597ea2['options']['limit']||null:null,'include':_0x597ea2['options']?_0x597ea2[_0xfc92('0x1a')][_0xfc92('0x1d')]?_[_0xfc92('0x1e')](_0x597ea2[_0xfc92('0x1a')][_0xfc92('0x1d')],function(_0xa43f14){return{'model':db[_0xa43f14[_0xfc92('0x1f')]],'as':_0xa43f14['as'],'attributes':_0xa43f14[_0xfc92('0x1c')],'include':_0xa43f14['include']?_[_0xfc92('0x1e')](_0xa43f14[_0xfc92('0x1d')],function(_0x35cea1){return{'model':db[_0x35cea1['model']],'as':_0x35cea1['as'],'attributes':_0x35cea1[_0xfc92('0x1c')],'include':_0x35cea1[_0xfc92('0x1d')]?_['map'](_0x35cea1['include'],function(_0x25de92){return{'model':db[_0x25de92[_0xfc92('0x1f')]],'as':_0x25de92['as'],'attributes':_0x25de92['attributes']};}):[]};}):[]};}):[]:[]})[_0xfc92('0xd')](function(_0x4d62fe){logger[_0xfc92('0xe')](_0xfc92('0x17'),_0x597ea2);logger['debug'](_0xfc92('0x17'),_0x597ea2,JSON[_0xfc92('0x13')](_0x4d62fe));_0x5ec474(_0x4d62fe);})[_0xfc92('0x16')](function(_0x3adb82){logger[_0xfc92('0x14')](_0xfc92('0x17'),_0x3adb82[_0xfc92('0x15')],_0x597ea2);_0x376551(_0x1f0b90[_0xfc92('0x14')](0x1f4,_0x3adb82[_0xfc92('0x15')]));});});};