6ed1725a24b10ee1cfa8be395840aad74cd747c8
[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 _0x9cfd=['where','attributes','map','include','model','debug','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','Sound,\x20%s,\x20%s,\x20%s','request\x20sent','code','Sound,\x20%s,\x20%s','error','message','info','result','catch','ShowSound','Sound','find','options'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x9cfd,0xd9));var _0xd9cf=function(_0x5d3bb9,_0x247237){_0x5d3bb9=_0x5d3bb9-0x0;var _0xa19bf9=_0x9cfd[_0x5d3bb9];return _0xa19bf9;};'use strict';var _=require(_0xd9cf('0x0'));var util=require(_0xd9cf('0x1'));var moment=require(_0xd9cf('0x2'));var BPromise=require(_0xd9cf('0x3'));var rs=require(_0xd9cf('0x4'));var fs=require('fs');var Redis=require(_0xd9cf('0x5'));var db=require(_0xd9cf('0x6'))['db'];var utils=require(_0xd9cf('0x7'));var logger=require(_0xd9cf('0x8'))(_0xd9cf('0x9'));var config=require('../../config/environment');var jayson=require(_0xd9cf('0xa'));var client=jayson[_0xd9cf('0xb')][_0xd9cf('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x15ffff,_0x42494a,_0x5f0de8){return new BPromise(function(_0x471d5c,_0x2156c5){return client[_0xd9cf('0xd')](_0x15ffff,_0x5f0de8)[_0xd9cf('0xe')](function(_0x489b39){logger['info']('Sound,\x20%s,\x20%s',_0x42494a,'request\x20sent');logger['debug'](_0xd9cf('0xf'),_0x42494a,_0xd9cf('0x10'),JSON['stringify'](_0x489b39));if(_0x489b39['error']){if(_0x489b39['error'][_0xd9cf('0x11')]===0x1f4){logger['error'](_0xd9cf('0x12'),_0x42494a,_0x489b39[_0xd9cf('0x13')][_0xd9cf('0x14')]);return _0x2156c5(_0x489b39[_0xd9cf('0x13')][_0xd9cf('0x14')]);}logger[_0xd9cf('0x13')](_0xd9cf('0x12'),_0x42494a,_0x489b39[_0xd9cf('0x13')][_0xd9cf('0x14')]);return _0x471d5c(_0x489b39[_0xd9cf('0x13')][_0xd9cf('0x14')]);}else{logger[_0xd9cf('0x15')](_0xd9cf('0x12'),_0x42494a,_0xd9cf('0x10'));_0x471d5c(_0x489b39[_0xd9cf('0x16')][_0xd9cf('0x14')]);}})[_0xd9cf('0x17')](function(_0x10e521){logger[_0xd9cf('0x13')](_0xd9cf('0x12'),_0x42494a,_0x10e521);_0x2156c5(_0x10e521);});});}exports[_0xd9cf('0x18')]=function(_0x153932){var _0x465f7f=this;return new Promise(function(_0x64b0a2,_0x23ba98){return db[_0xd9cf('0x19')][_0xd9cf('0x1a')]({'raw':_0x153932['options']?_0x153932[_0xd9cf('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x153932[_0xd9cf('0x1b')]?_0x153932['options'][_0xd9cf('0x1c')]||null:null,'attributes':_0x153932[_0xd9cf('0x1b')]?_0x153932['options'][_0xd9cf('0x1d')]||null:null,'include':_0x153932[_0xd9cf('0x1b')]?_0x153932[_0xd9cf('0x1b')]['include']?_[_0xd9cf('0x1e')](_0x153932['options'][_0xd9cf('0x1f')],function(_0x389310){return{'model':db[_0x389310[_0xd9cf('0x20')]],'as':_0x389310['as'],'attributes':_0x389310[_0xd9cf('0x1d')],'include':_0x389310[_0xd9cf('0x1f')]?_['map'](_0x389310[_0xd9cf('0x1f')],function(_0x3db0c6){return{'model':db[_0x3db0c6[_0xd9cf('0x20')]],'as':_0x3db0c6['as'],'attributes':_0x3db0c6['attributes'],'include':_0x3db0c6['include']?_[_0xd9cf('0x1e')](_0x3db0c6[_0xd9cf('0x1f')],function(_0x5639d5){return{'model':db[_0x5639d5[_0xd9cf('0x20')]],'as':_0x5639d5['as'],'attributes':_0x5639d5[_0xd9cf('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x43eb53){logger[_0xd9cf('0x15')](_0xd9cf('0x18'),_0x153932);logger[_0xd9cf('0x21')]('ShowSound',_0x153932,JSON[_0xd9cf('0x22')](_0x43eb53));_0x64b0a2(_0x43eb53);})['catch'](function(_0x3dad9a){logger[_0xd9cf('0x13')](_0xd9cf('0x18'),_0x3dad9a['message'],_0x153932);_0x23ba98(_0x465f7f[_0xd9cf('0x13')](0x1f4,_0x3dad9a[_0xd9cf('0x14')]));});});};