1fa1a613831b4fead92caf60bb8e267356f29362
[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 _0x6990=['stringify','error','code','message','info','result','catch','ShowSound','Sound','find','options','raw','attributes','include','model','map','debug','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','Sound,\x20%s,\x20%s','request\x20sent','Sound,\x20%s,\x20%s,\x20%s'];(function(_0x5392a2,_0x3d6fba){var _0x4c59d7=function(_0x378e34){while(--_0x378e34){_0x5392a2['push'](_0x5392a2['shift']());}};_0x4c59d7(++_0x3d6fba);}(_0x6990,0x129));var _0x0699=function(_0xf01016,_0x1ce928){_0xf01016=_0xf01016-0x0;var _0x1fdee6=_0x6990[_0xf01016];return _0x1fdee6;};'use strict';var _=require(_0x0699('0x0'));var util=require(_0x0699('0x1'));var moment=require(_0x0699('0x2'));var BPromise=require(_0x0699('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0699('0x4'));var db=require(_0x0699('0x5'))['db'];var utils=require(_0x0699('0x6'));var logger=require(_0x0699('0x7'))(_0x0699('0x8'));var config=require(_0x0699('0x9'));var jayson=require(_0x0699('0xa'));var client=jayson[_0x0699('0xb')][_0x0699('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x3a392f,_0x22c7ad,_0x26a80b){return new BPromise(function(_0x2c2c37,_0x13f2e1){return client[_0x0699('0xd')](_0x3a392f,_0x26a80b)[_0x0699('0xe')](function(_0x471358){logger['info'](_0x0699('0xf'),_0x22c7ad,_0x0699('0x10'));logger['debug'](_0x0699('0x11'),_0x22c7ad,_0x0699('0x10'),JSON[_0x0699('0x12')](_0x471358));if(_0x471358[_0x0699('0x13')]){if(_0x471358[_0x0699('0x13')][_0x0699('0x14')]===0x1f4){logger[_0x0699('0x13')](_0x0699('0xf'),_0x22c7ad,_0x471358[_0x0699('0x13')][_0x0699('0x15')]);return _0x13f2e1(_0x471358[_0x0699('0x13')][_0x0699('0x15')]);}logger[_0x0699('0x13')](_0x0699('0xf'),_0x22c7ad,_0x471358[_0x0699('0x13')][_0x0699('0x15')]);return _0x2c2c37(_0x471358[_0x0699('0x13')]['message']);}else{logger[_0x0699('0x16')](_0x0699('0xf'),_0x22c7ad,'request\x20sent');_0x2c2c37(_0x471358[_0x0699('0x17')][_0x0699('0x15')]);}})[_0x0699('0x18')](function(_0x5c0052){logger[_0x0699('0x13')](_0x0699('0xf'),_0x22c7ad,_0x5c0052);_0x13f2e1(_0x5c0052);});});}exports[_0x0699('0x19')]=function(_0x190cb7){var _0x1271a9=this;return new Promise(function(_0x561c6c,_0x1315f6){return db[_0x0699('0x1a')][_0x0699('0x1b')]({'raw':_0x190cb7[_0x0699('0x1c')]?_0x190cb7[_0x0699('0x1c')][_0x0699('0x1d')]===undefined?!![]:![]:!![],'where':_0x190cb7[_0x0699('0x1c')]?_0x190cb7[_0x0699('0x1c')]['where']||null:null,'attributes':_0x190cb7[_0x0699('0x1c')]?_0x190cb7[_0x0699('0x1c')][_0x0699('0x1e')]||null:null,'include':_0x190cb7[_0x0699('0x1c')]?_0x190cb7[_0x0699('0x1c')]['include']?_['map'](_0x190cb7[_0x0699('0x1c')][_0x0699('0x1f')],function(_0x1a2241){return{'model':db[_0x1a2241[_0x0699('0x20')]],'as':_0x1a2241['as'],'attributes':_0x1a2241[_0x0699('0x1e')],'include':_0x1a2241[_0x0699('0x1f')]?_[_0x0699('0x21')](_0x1a2241['include'],function(_0x4998db){return{'model':db[_0x4998db[_0x0699('0x20')]],'as':_0x4998db['as'],'attributes':_0x4998db['attributes'],'include':_0x4998db[_0x0699('0x1f')]?_[_0x0699('0x21')](_0x4998db[_0x0699('0x1f')],function(_0x51a21c){return{'model':db[_0x51a21c[_0x0699('0x20')]],'as':_0x51a21c['as'],'attributes':_0x51a21c[_0x0699('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x0699('0xe')](function(_0x99ca6d){logger[_0x0699('0x16')](_0x0699('0x19'),_0x190cb7);logger[_0x0699('0x22')](_0x0699('0x19'),_0x190cb7,JSON[_0x0699('0x12')](_0x99ca6d));_0x561c6c(_0x99ca6d);})[_0x0699('0x18')](function(_0x168965){logger[_0x0699('0x13')](_0x0699('0x19'),_0x168965[_0x0699('0x15')],_0x190cb7);_0x1315f6(_0x1271a9[_0x0699('0x13')](0x1f4,_0x168965[_0x0699('0x15')]));});});};