586ea981c8786d0742ba993e96ce83b52f640716
[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 _0x4e11=['http','request','info','Sound,\x20%s,\x20%s','request\x20sent','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','ShowSound','Sound','find','options','where','attributes','include','map','model','util','moment','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client'];(function(_0x2f4ebb,_0x3d8f4e){var _0x5c141a=function(_0x29b11e){while(--_0x29b11e){_0x2f4ebb['push'](_0x2f4ebb['shift']());}};_0x5c141a(++_0x3d8f4e);}(_0x4e11,0xa5));var _0x14e1=function(_0x3f8f4b,_0x468f9f){_0x3f8f4b=_0x3f8f4b-0x0;var _0x43135c=_0x4e11[_0x3f8f4b];return _0x43135c;};'use strict';var _=require('lodash');var util=require(_0x14e1('0x0'));var moment=require(_0x14e1('0x1'));var BPromise=require(_0x14e1('0x2'));var rs=require(_0x14e1('0x3'));var fs=require('fs');var Redis=require(_0x14e1('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x14e1('0x5'))('rpc');var config=require(_0x14e1('0x6'));var jayson=require(_0x14e1('0x7'));var client=jayson[_0x14e1('0x8')][_0x14e1('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x496fc5,_0x44d47d,_0x21f846){return new BPromise(function(_0x3a7ee3,_0x2cad64){return client[_0x14e1('0xa')](_0x496fc5,_0x21f846)['then'](function(_0x3725ca){logger[_0x14e1('0xb')](_0x14e1('0xc'),_0x44d47d,_0x14e1('0xd'));logger[_0x14e1('0xe')](_0x14e1('0xf'),_0x44d47d,_0x14e1('0xd'),JSON[_0x14e1('0x10')](_0x3725ca));if(_0x3725ca['error']){if(_0x3725ca[_0x14e1('0x11')]['code']===0x1f4){logger['error'](_0x14e1('0xc'),_0x44d47d,_0x3725ca[_0x14e1('0x11')][_0x14e1('0x12')]);return _0x2cad64(_0x3725ca[_0x14e1('0x11')][_0x14e1('0x12')]);}logger[_0x14e1('0x11')]('Sound,\x20%s,\x20%s',_0x44d47d,_0x3725ca[_0x14e1('0x11')][_0x14e1('0x12')]);return _0x3a7ee3(_0x3725ca[_0x14e1('0x11')][_0x14e1('0x12')]);}else{logger[_0x14e1('0xb')](_0x14e1('0xc'),_0x44d47d,_0x14e1('0xd'));_0x3a7ee3(_0x3725ca['result']['message']);}})[_0x14e1('0x13')](function(_0x34b203){logger[_0x14e1('0x11')](_0x14e1('0xc'),_0x44d47d,_0x34b203);_0x2cad64(_0x34b203);});});}exports[_0x14e1('0x14')]=function(_0x510017){var _0x149485=this;return new Promise(function(_0x254566,_0x12f0ea){return db[_0x14e1('0x15')][_0x14e1('0x16')]({'raw':_0x510017[_0x14e1('0x17')]?_0x510017[_0x14e1('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x510017[_0x14e1('0x17')]?_0x510017[_0x14e1('0x17')][_0x14e1('0x18')]||null:null,'attributes':_0x510017[_0x14e1('0x17')]?_0x510017[_0x14e1('0x17')][_0x14e1('0x19')]||null:null,'include':_0x510017['options']?_0x510017[_0x14e1('0x17')][_0x14e1('0x1a')]?_[_0x14e1('0x1b')](_0x510017['options']['include'],function(_0x386200){return{'model':db[_0x386200[_0x14e1('0x1c')]],'as':_0x386200['as'],'attributes':_0x386200[_0x14e1('0x19')],'include':_0x386200[_0x14e1('0x1a')]?_[_0x14e1('0x1b')](_0x386200[_0x14e1('0x1a')],function(_0x44538f){return{'model':db[_0x44538f['model']],'as':_0x44538f['as'],'attributes':_0x44538f[_0x14e1('0x19')],'include':_0x44538f[_0x14e1('0x1a')]?_[_0x14e1('0x1b')](_0x44538f[_0x14e1('0x1a')],function(_0x3821c6){return{'model':db[_0x3821c6[_0x14e1('0x1c')]],'as':_0x3821c6['as'],'attributes':_0x3821c6[_0x14e1('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x8804c4){logger['info'](_0x14e1('0x14'),_0x510017);logger['debug'](_0x14e1('0x14'),_0x510017,JSON['stringify'](_0x8804c4));_0x254566(_0x8804c4);})[_0x14e1('0x13')](function(_0x251857){logger[_0x14e1('0x11')](_0x14e1('0x14'),_0x251857['message'],_0x510017);_0x12f0ea(_0x149485[_0x14e1('0x11')](0x1f4,_0x251857[_0x14e1('0x12')]));});});};