e9cb5a29a36ba48ed99114d0892b97638b448da2
[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 _0x6d82=['client','http','request','then','Sound,\x20%s,\x20%s','debug','Sound,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','ShowSound','find','options','raw','where','attributes','include','map','model','catch','lodash','util','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x307eff,_0x2228ae){var _0x32bbd9=function(_0xb3652f){while(--_0xb3652f){_0x307eff['push'](_0x307eff['shift']());}};_0x32bbd9(++_0x2228ae);}(_0x6d82,0x158));var _0x26d8=function(_0xd8ad2e,_0xdddfe2){_0xd8ad2e=_0xd8ad2e-0x0;var _0x291e10=_0x6d82[_0xd8ad2e];return _0x291e10;};'use strict';var _=require(_0x26d8('0x0'));var util=require(_0x26d8('0x1'));var moment=require('moment');var BPromise=require(_0x26d8('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x26d8('0x3'))['db'];var utils=require(_0x26d8('0x4'));var logger=require(_0x26d8('0x5'))(_0x26d8('0x6'));var config=require('../../config/environment');var jayson=require(_0x26d8('0x7'));var client=jayson[_0x26d8('0x8')][_0x26d8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x5b297a,_0x482072,_0x467a8e){return new BPromise(function(_0x608e9b,_0x574939){return client[_0x26d8('0xa')](_0x5b297a,_0x467a8e)[_0x26d8('0xb')](function(_0x5c9308){logger['info'](_0x26d8('0xc'),_0x482072,'request\x20sent');logger[_0x26d8('0xd')](_0x26d8('0xe'),_0x482072,_0x26d8('0xf'),JSON[_0x26d8('0x10')](_0x5c9308));if(_0x5c9308[_0x26d8('0x11')]){if(_0x5c9308[_0x26d8('0x11')][_0x26d8('0x12')]===0x1f4){logger['error'](_0x26d8('0xc'),_0x482072,_0x5c9308[_0x26d8('0x11')][_0x26d8('0x13')]);return _0x574939(_0x5c9308[_0x26d8('0x11')][_0x26d8('0x13')]);}logger[_0x26d8('0x11')](_0x26d8('0xc'),_0x482072,_0x5c9308[_0x26d8('0x11')][_0x26d8('0x13')]);return _0x608e9b(_0x5c9308[_0x26d8('0x11')]['message']);}else{logger[_0x26d8('0x14')](_0x26d8('0xc'),_0x482072,_0x26d8('0xf'));_0x608e9b(_0x5c9308[_0x26d8('0x15')][_0x26d8('0x13')]);}})['catch'](function(_0x59df2b){logger['error'](_0x26d8('0xc'),_0x482072,_0x59df2b);_0x574939(_0x59df2b);});});}exports[_0x26d8('0x16')]=function(_0x9f2215){var _0x24b4ee=this;return new Promise(function(_0x20fca0,_0x3d5e24){return db['Sound'][_0x26d8('0x17')]({'raw':_0x9f2215['options']?_0x9f2215[_0x26d8('0x18')][_0x26d8('0x19')]===undefined?!![]:![]:!![],'where':_0x9f2215[_0x26d8('0x18')]?_0x9f2215[_0x26d8('0x18')][_0x26d8('0x1a')]||null:null,'attributes':_0x9f2215['options']?_0x9f2215['options'][_0x26d8('0x1b')]||null:null,'include':_0x9f2215[_0x26d8('0x18')]?_0x9f2215[_0x26d8('0x18')][_0x26d8('0x1c')]?_[_0x26d8('0x1d')](_0x9f2215[_0x26d8('0x18')][_0x26d8('0x1c')],function(_0xf7dae6){return{'model':db[_0xf7dae6[_0x26d8('0x1e')]],'as':_0xf7dae6['as'],'attributes':_0xf7dae6['attributes'],'include':_0xf7dae6[_0x26d8('0x1c')]?_[_0x26d8('0x1d')](_0xf7dae6[_0x26d8('0x1c')],function(_0x1faf13){return{'model':db[_0x1faf13[_0x26d8('0x1e')]],'as':_0x1faf13['as'],'attributes':_0x1faf13[_0x26d8('0x1b')],'include':_0x1faf13[_0x26d8('0x1c')]?_[_0x26d8('0x1d')](_0x1faf13[_0x26d8('0x1c')],function(_0x45e806){return{'model':db[_0x45e806[_0x26d8('0x1e')]],'as':_0x45e806['as'],'attributes':_0x45e806['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x28b68a){logger['info'](_0x26d8('0x16'),_0x9f2215);logger[_0x26d8('0xd')](_0x26d8('0x16'),_0x9f2215,JSON['stringify'](_0x28b68a));_0x20fca0(_0x28b68a);})[_0x26d8('0x1f')](function(_0x389933){logger[_0x26d8('0x11')]('ShowSound',_0x389933[_0x26d8('0x13')],_0x9f2215);_0x3d5e24(_0x24b4ee[_0x26d8('0x11')](0x1f4,_0x389933[_0x26d8('0x13')]));});});};