983de6b308b2619ae128908dff63452961059839
[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 _0x589a=['catch','lodash','moment','randomstring','ioredis','../../config/utils','jayson/promise','http','request','then','info','Sound,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','ShowSound','Sound','find','options','raw','where','attributes','include','model','map'];(function(_0x86c6cb,_0x30bb53){var _0x1b1592=function(_0x19e1c9){while(--_0x19e1c9){_0x86c6cb['push'](_0x86c6cb['shift']());}};_0x1b1592(++_0x30bb53);}(_0x589a,0x1e7));var _0xa589=function(_0x25cfe3,_0xd13431){_0x25cfe3=_0x25cfe3-0x0;var _0x4f9f02=_0x589a[_0x25cfe3];return _0x4f9f02;};'use strict';var _=require(_0xa589('0x0'));var util=require('util');var moment=require(_0xa589('0x1'));var BPromise=require('bluebird');var rs=require(_0xa589('0x2'));var fs=require('fs');var Redis=require(_0xa589('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xa589('0x4'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xa589('0x5'));var client=jayson['client'][_0xa589('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x2eaaaf,_0x5142f6,_0x12bd4f){return new BPromise(function(_0x1e657f,_0x2466b6){return client[_0xa589('0x7')](_0x2eaaaf,_0x12bd4f)[_0xa589('0x8')](function(_0x1d3db1){logger[_0xa589('0x9')](_0xa589('0xa'),_0x5142f6,_0xa589('0xb'));logger[_0xa589('0xc')]('Sound,\x20%s,\x20%s,\x20%s',_0x5142f6,_0xa589('0xb'),JSON[_0xa589('0xd')](_0x1d3db1));if(_0x1d3db1[_0xa589('0xe')]){if(_0x1d3db1[_0xa589('0xe')]['code']===0x1f4){logger[_0xa589('0xe')](_0xa589('0xa'),_0x5142f6,_0x1d3db1[_0xa589('0xe')][_0xa589('0xf')]);return _0x2466b6(_0x1d3db1['error'][_0xa589('0xf')]);}logger[_0xa589('0xe')](_0xa589('0xa'),_0x5142f6,_0x1d3db1['error'][_0xa589('0xf')]);return _0x1e657f(_0x1d3db1[_0xa589('0xe')]['message']);}else{logger['info']('Sound,\x20%s,\x20%s',_0x5142f6,_0xa589('0xb'));_0x1e657f(_0x1d3db1['result'][_0xa589('0xf')]);}})['catch'](function(_0x29be28){logger[_0xa589('0xe')](_0xa589('0xa'),_0x5142f6,_0x29be28);_0x2466b6(_0x29be28);});});}exports[_0xa589('0x10')]=function(_0x5e7b43){var _0x421005=this;return new Promise(function(_0x28da36,_0x22199e){return db[_0xa589('0x11')][_0xa589('0x12')]({'raw':_0x5e7b43['options']?_0x5e7b43[_0xa589('0x13')][_0xa589('0x14')]===undefined?!![]:![]:!![],'where':_0x5e7b43[_0xa589('0x13')]?_0x5e7b43[_0xa589('0x13')][_0xa589('0x15')]||null:null,'attributes':_0x5e7b43[_0xa589('0x13')]?_0x5e7b43[_0xa589('0x13')][_0xa589('0x16')]||null:null,'include':_0x5e7b43['options']?_0x5e7b43[_0xa589('0x13')]['include']?_['map'](_0x5e7b43['options'][_0xa589('0x17')],function(_0x3867ea){return{'model':db[_0x3867ea[_0xa589('0x18')]],'as':_0x3867ea['as'],'attributes':_0x3867ea[_0xa589('0x16')],'include':_0x3867ea[_0xa589('0x17')]?_['map'](_0x3867ea[_0xa589('0x17')],function(_0x29e010){return{'model':db[_0x29e010[_0xa589('0x18')]],'as':_0x29e010['as'],'attributes':_0x29e010[_0xa589('0x16')],'include':_0x29e010['include']?_[_0xa589('0x19')](_0x29e010[_0xa589('0x17')],function(_0x26a911){return{'model':db[_0x26a911[_0xa589('0x18')]],'as':_0x26a911['as'],'attributes':_0x26a911[_0xa589('0x16')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1cca89){logger[_0xa589('0x9')](_0xa589('0x10'),_0x5e7b43);logger[_0xa589('0xc')](_0xa589('0x10'),_0x5e7b43,JSON[_0xa589('0xd')](_0x1cca89));_0x28da36(_0x1cca89);})[_0xa589('0x1a')](function(_0xb67f6a){logger[_0xa589('0xe')]('ShowSound',_0xb67f6a['message'],_0x5e7b43);_0x22199e(_0x421005[_0xa589('0xe')](0x1f4,_0xb67f6a[_0xa589('0xf')]));});});};