Built motion from commit (unavailable).|2.0.79
[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 _0x3a79=['map','then','ShowSound','util','moment','bluebird','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','info','Sound,\x20%s,\x20%s','request\x20sent','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','Sound','find','options','where','attributes','model','include'];(function(_0x23b6f8,_0x2ec372){var _0x114fee=function(_0x1a92db){while(--_0x1a92db){_0x23b6f8['push'](_0x23b6f8['shift']());}};_0x114fee(++_0x2ec372);}(_0x3a79,0x7b));var _0x93a7=function(_0x29df1a,_0xd0e1aa){_0x29df1a=_0x29df1a-0x0;var _0x3343a9=_0x3a79[_0x29df1a];return _0x3343a9;};'use strict';var _=require('lodash');var util=require(_0x93a7('0x0'));var moment=require(_0x93a7('0x1'));var BPromise=require(_0x93a7('0x2'));var rs=require('randomstring');var fs=require('fs');var db=require(_0x93a7('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x93a7('0x4'))(_0x93a7('0x5'));var config=require(_0x93a7('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x93a7('0x7')][_0x93a7('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x799203,_0x1348ba,_0x1f011d){return new BPromise(function(_0x3d28ac,_0x4d42e3){return client[_0x93a7('0x9')](_0x799203,_0x1f011d)['then'](function(_0x3f4ca5){logger[_0x93a7('0xa')](_0x93a7('0xb'),_0x1348ba,_0x93a7('0xc'));logger[_0x93a7('0xd')](_0x93a7('0xe'),_0x1348ba,_0x93a7('0xc'),JSON[_0x93a7('0xf')](_0x3f4ca5));if(_0x3f4ca5[_0x93a7('0x10')]){if(_0x3f4ca5[_0x93a7('0x10')][_0x93a7('0x11')]===0x1f4){logger[_0x93a7('0x10')](_0x93a7('0xb'),_0x1348ba,_0x3f4ca5['error'][_0x93a7('0x12')]);return _0x4d42e3(_0x3f4ca5[_0x93a7('0x10')][_0x93a7('0x12')]);}logger[_0x93a7('0x10')]('Sound,\x20%s,\x20%s',_0x1348ba,_0x3f4ca5['error']['message']);return _0x3d28ac(_0x3f4ca5['error'][_0x93a7('0x12')]);}else{logger[_0x93a7('0xa')](_0x93a7('0xb'),_0x1348ba,_0x93a7('0xc'));_0x3d28ac(_0x3f4ca5[_0x93a7('0x13')][_0x93a7('0x12')]);}})['catch'](function(_0x36477e){logger[_0x93a7('0x10')](_0x93a7('0xb'),_0x1348ba,_0x36477e);_0x4d42e3(_0x36477e);});});}exports['ShowSound']=function(_0x1f21cb){var _0x1d4c74=this;return new Promise(function(_0x306b82,_0x13149f){return db[_0x93a7('0x14')][_0x93a7('0x15')]({'raw':_0x1f21cb['options']?_0x1f21cb[_0x93a7('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x1f21cb['options']?_0x1f21cb[_0x93a7('0x16')][_0x93a7('0x17')]||null:null,'attributes':_0x1f21cb['options']?_0x1f21cb[_0x93a7('0x16')][_0x93a7('0x18')]||null:null,'include':_0x1f21cb[_0x93a7('0x16')]?_0x1f21cb['options']['include']?_['map'](_0x1f21cb[_0x93a7('0x16')]['include'],function(_0x5d1c2f){return{'model':db[_0x5d1c2f[_0x93a7('0x19')]],'as':_0x5d1c2f['as'],'attributes':_0x5d1c2f['attributes'],'include':_0x5d1c2f['include']?_['map'](_0x5d1c2f[_0x93a7('0x1a')],function(_0x5594f9){return{'model':db[_0x5594f9['model']],'as':_0x5594f9['as'],'attributes':_0x5594f9['attributes'],'include':_0x5594f9[_0x93a7('0x1a')]?_[_0x93a7('0x1b')](_0x5594f9[_0x93a7('0x1a')],function(_0x4ebc82){return{'model':db[_0x4ebc82['model']],'as':_0x4ebc82['as'],'attributes':_0x4ebc82[_0x93a7('0x18')]};}):[]};}):[]};}):[]:[]})[_0x93a7('0x1c')](function(_0x4d2c1d){logger['info']('ShowSound',_0x1f21cb);logger[_0x93a7('0xd')](_0x93a7('0x1d'),_0x1f21cb,JSON[_0x93a7('0xf')](_0x4d2c1d));_0x306b82(_0x4d2c1d);})['catch'](function(_0x23c1d4){logger[_0x93a7('0x10')](_0x93a7('0x1d'),_0x23c1d4['message'],_0x1f21cb);_0x13149f(_0x1d4c74[_0x93a7('0x10')](0x1f4,_0x23c1d4[_0x93a7('0x12')]));});});};