c99df0bb78b2c1cb15d2327ea072cabcb5540aac
[motion2.git] / server / api / sound / sound.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 _0x17c3=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','info','request\x20sent','error','code','Sound,\x20%s,\x20%s','message','ShowSound','Sound','find','options','raw','where','attributes','include','map','model','then','debug','util','moment','bluebird','randomstring','ioredis'];(function(_0x2e6cea,_0x5d56f4){var _0x2962e9=function(_0x3ea209){while(--_0x3ea209){_0x2e6cea['push'](_0x2e6cea['shift']());}};_0x2962e9(++_0x5d56f4);}(_0x17c3,0x191));var _0x317c=function(_0xf2f94a,_0x182b37){_0xf2f94a=_0xf2f94a-0x0;var _0x1cb10e=_0x17c3[_0xf2f94a];return _0x1cb10e;};'use strict';var _=require('lodash');var util=require(_0x317c('0x0'));var moment=require(_0x317c('0x1'));var BPromise=require(_0x317c('0x2'));var rs=require(_0x317c('0x3'));var fs=require('fs');var Redis=require(_0x317c('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x317c('0x5'));var logger=require(_0x317c('0x6'))(_0x317c('0x7'));var config=require(_0x317c('0x8'));var jayson=require(_0x317c('0x9'));var client=jayson[_0x317c('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2c3350,_0x2691fb,_0x455b13){return new BPromise(function(_0x37e308,_0x577bd7){return client['request'](_0x2c3350,_0x455b13)['then'](function(_0x3ef076){logger[_0x317c('0xb')]('Sound,\x20%s,\x20%s',_0x2691fb,'request\x20sent');logger['debug']('Sound,\x20%s,\x20%s,\x20%s',_0x2691fb,_0x317c('0xc'),JSON['stringify'](_0x3ef076));if(_0x3ef076[_0x317c('0xd')]){if(_0x3ef076[_0x317c('0xd')][_0x317c('0xe')]===0x1f4){logger[_0x317c('0xd')](_0x317c('0xf'),_0x2691fb,_0x3ef076[_0x317c('0xd')][_0x317c('0x10')]);return _0x577bd7(_0x3ef076[_0x317c('0xd')][_0x317c('0x10')]);}logger[_0x317c('0xd')](_0x317c('0xf'),_0x2691fb,_0x3ef076[_0x317c('0xd')][_0x317c('0x10')]);return _0x37e308(_0x3ef076[_0x317c('0xd')][_0x317c('0x10')]);}else{logger[_0x317c('0xb')](_0x317c('0xf'),_0x2691fb,_0x317c('0xc'));_0x37e308(_0x3ef076['result'][_0x317c('0x10')]);}})['catch'](function(_0x51689b){logger[_0x317c('0xd')]('Sound,\x20%s,\x20%s',_0x2691fb,_0x51689b);_0x577bd7(_0x51689b);});});}exports[_0x317c('0x11')]=function(_0x45ceb1){var _0x163e26=this;return new Promise(function(_0x1b33e8,_0x11025d){return db[_0x317c('0x12')][_0x317c('0x13')]({'raw':_0x45ceb1[_0x317c('0x14')]?_0x45ceb1[_0x317c('0x14')][_0x317c('0x15')]===undefined?!![]:![]:!![],'where':_0x45ceb1['options']?_0x45ceb1['options'][_0x317c('0x16')]||null:null,'attributes':_0x45ceb1[_0x317c('0x14')]?_0x45ceb1['options'][_0x317c('0x17')]||null:null,'include':_0x45ceb1[_0x317c('0x14')]?_0x45ceb1[_0x317c('0x14')][_0x317c('0x18')]?_[_0x317c('0x19')](_0x45ceb1[_0x317c('0x14')][_0x317c('0x18')],function(_0x432439){return{'model':db[_0x432439['model']],'as':_0x432439['as'],'attributes':_0x432439[_0x317c('0x17')],'include':_0x432439['include']?_['map'](_0x432439['include'],function(_0x5cb7c2){return{'model':db[_0x5cb7c2[_0x317c('0x1a')]],'as':_0x5cb7c2['as'],'attributes':_0x5cb7c2[_0x317c('0x17')],'include':_0x5cb7c2[_0x317c('0x18')]?_['map'](_0x5cb7c2['include'],function(_0x1c7064){return{'model':db[_0x1c7064[_0x317c('0x1a')]],'as':_0x1c7064['as'],'attributes':_0x1c7064['attributes']};}):[]};}):[]};}):[]:[]})[_0x317c('0x1b')](function(_0x5e9807){logger[_0x317c('0xb')](_0x317c('0x11'),_0x45ceb1);logger[_0x317c('0x1c')]('ShowSound',_0x45ceb1,JSON['stringify'](_0x5e9807));_0x1b33e8(_0x5e9807);})['catch'](function(_0x3e7531){logger['error'](_0x317c('0x11'),_0x3e7531[_0x317c('0x10')],_0x45ceb1);_0x11025d(_0x163e26[_0x317c('0xd')](0x1f4,_0x3e7531['message']));});});};