61bd000bcaeaf90347b28ced7aa24352dbacd81c
[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 _0x194a=['http','request','info','Sound,\x20%s,\x20%s','debug','Sound,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','catch','options','raw','where','attributes','include','map','model','then','ShowSound','stringify','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x3020fc,_0x242d93){var _0x304235=function(_0x284dd1){while(--_0x284dd1){_0x3020fc['push'](_0x3020fc['shift']());}};_0x304235(++_0x242d93);}(_0x194a,0xaa));var _0xa194=function(_0x5a2285,_0x3212d1){_0x5a2285=_0x5a2285-0x0;var _0x48f6ed=_0x194a[_0x5a2285];return _0x48f6ed;};'use strict';var _=require(_0xa194('0x0'));var util=require(_0xa194('0x1'));var moment=require(_0xa194('0x2'));var BPromise=require(_0xa194('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa194('0x4'))['db'];var utils=require(_0xa194('0x5'));var logger=require(_0xa194('0x6'))(_0xa194('0x7'));var config=require(_0xa194('0x8'));var jayson=require(_0xa194('0x9'));var client=jayson['client'][_0xa194('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2a5d78,_0x1298e,_0x1509c0){return new BPromise(function(_0x1f17c8,_0x42347d){return client[_0xa194('0xb')](_0x2a5d78,_0x1509c0)['then'](function(_0x19b1c8){logger[_0xa194('0xc')](_0xa194('0xd'),_0x1298e,'request\x20sent');logger[_0xa194('0xe')](_0xa194('0xf'),_0x1298e,_0xa194('0x10'),JSON['stringify'](_0x19b1c8));if(_0x19b1c8[_0xa194('0x11')]){if(_0x19b1c8[_0xa194('0x11')]['code']===0x1f4){logger['error'](_0xa194('0xd'),_0x1298e,_0x19b1c8[_0xa194('0x11')][_0xa194('0x12')]);return _0x42347d(_0x19b1c8[_0xa194('0x11')][_0xa194('0x12')]);}logger['error'](_0xa194('0xd'),_0x1298e,_0x19b1c8['error'][_0xa194('0x12')]);return _0x1f17c8(_0x19b1c8[_0xa194('0x11')][_0xa194('0x12')]);}else{logger[_0xa194('0xc')](_0xa194('0xd'),_0x1298e,'request\x20sent');_0x1f17c8(_0x19b1c8['result'][_0xa194('0x12')]);}})[_0xa194('0x13')](function(_0x5cc726){logger[_0xa194('0x11')](_0xa194('0xd'),_0x1298e,_0x5cc726);_0x42347d(_0x5cc726);});});}exports['ShowSound']=function(_0x52c534){var _0x261386=this;return new Promise(function(_0x2f0a13,_0x4d76ee){return db['Sound']['find']({'raw':_0x52c534['options']?_0x52c534[_0xa194('0x14')][_0xa194('0x15')]===undefined?!![]:![]:!![],'where':_0x52c534[_0xa194('0x14')]?_0x52c534[_0xa194('0x14')][_0xa194('0x16')]||null:null,'attributes':_0x52c534[_0xa194('0x14')]?_0x52c534[_0xa194('0x14')][_0xa194('0x17')]||null:null,'include':_0x52c534[_0xa194('0x14')]?_0x52c534[_0xa194('0x14')][_0xa194('0x18')]?_[_0xa194('0x19')](_0x52c534[_0xa194('0x14')]['include'],function(_0x1c583b){return{'model':db[_0x1c583b[_0xa194('0x1a')]],'as':_0x1c583b['as'],'attributes':_0x1c583b[_0xa194('0x17')],'include':_0x1c583b['include']?_[_0xa194('0x19')](_0x1c583b[_0xa194('0x18')],function(_0x3522ab){return{'model':db[_0x3522ab[_0xa194('0x1a')]],'as':_0x3522ab['as'],'attributes':_0x3522ab['attributes'],'include':_0x3522ab[_0xa194('0x18')]?_[_0xa194('0x19')](_0x3522ab[_0xa194('0x18')],function(_0x4efde5){return{'model':db[_0x4efde5[_0xa194('0x1a')]],'as':_0x4efde5['as'],'attributes':_0x4efde5['attributes']};}):[]};}):[]};}):[]:[]})[_0xa194('0x1b')](function(_0x379e1c){logger[_0xa194('0xc')](_0xa194('0x1c'),_0x52c534);logger[_0xa194('0xe')](_0xa194('0x1c'),_0x52c534,JSON[_0xa194('0x1d')](_0x379e1c));_0x2f0a13(_0x379e1c);})[_0xa194('0x13')](function(_0x4140bc){logger[_0xa194('0x11')]('ShowSound',_0x4140bc[_0xa194('0x12')],_0x52c534);_0x4d76ee(_0x261386[_0xa194('0x11')](0x1f4,_0x4140bc[_0xa194('0x12')]));});});};