71a16cf8e767a49f55e61056994fd4b554853781
[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 _0xf367=['options','raw','where','include','map','model','attributes','debug','util','moment','bluebird','ioredis','../../config/utils','../../config/environment','client','then','info','Sound,\x20%s,\x20%s','request\x20sent','Sound,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','ShowSound','Sound','find'];(function(_0x37d2c6,_0x5d68e3){var _0xa2cc99=function(_0x417c54){while(--_0x417c54){_0x37d2c6['push'](_0x37d2c6['shift']());}};_0xa2cc99(++_0x5d68e3);}(_0xf367,0x120));var _0x7f36=function(_0x522d0e,_0x1be748){_0x522d0e=_0x522d0e-0x0;var _0x5c0e1e=_0xf367[_0x522d0e];return _0x5c0e1e;};'use strict';var _=require('lodash');var util=require(_0x7f36('0x0'));var moment=require(_0x7f36('0x1'));var BPromise=require(_0x7f36('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7f36('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x7f36('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0x7f36('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x7f36('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0xe337a9,_0x517fe4,_0x10a879){return new BPromise(function(_0x38ee33,_0x38c6e0){return client['request'](_0xe337a9,_0x10a879)[_0x7f36('0x7')](function(_0x4fa84b){logger[_0x7f36('0x8')](_0x7f36('0x9'),_0x517fe4,_0x7f36('0xa'));logger['debug'](_0x7f36('0xb'),_0x517fe4,_0x7f36('0xa'),JSON[_0x7f36('0xc')](_0x4fa84b));if(_0x4fa84b['error']){if(_0x4fa84b[_0x7f36('0xd')][_0x7f36('0xe')]===0x1f4){logger[_0x7f36('0xd')](_0x7f36('0x9'),_0x517fe4,_0x4fa84b['error']['message']);return _0x38c6e0(_0x4fa84b['error']['message']);}logger[_0x7f36('0xd')]('Sound,\x20%s,\x20%s',_0x517fe4,_0x4fa84b[_0x7f36('0xd')][_0x7f36('0xf')]);return _0x38ee33(_0x4fa84b[_0x7f36('0xd')][_0x7f36('0xf')]);}else{logger['info'](_0x7f36('0x9'),_0x517fe4,_0x7f36('0xa'));_0x38ee33(_0x4fa84b['result'][_0x7f36('0xf')]);}})[_0x7f36('0x10')](function(_0x38a6ce){logger[_0x7f36('0xd')](_0x7f36('0x9'),_0x517fe4,_0x38a6ce);_0x38c6e0(_0x38a6ce);});});}exports[_0x7f36('0x11')]=function(_0x1e6371){var _0x2a48a8=this;return new Promise(function(_0x5aca2a,_0x1100fb){return db[_0x7f36('0x12')][_0x7f36('0x13')]({'raw':_0x1e6371[_0x7f36('0x14')]?_0x1e6371[_0x7f36('0x14')][_0x7f36('0x15')]===undefined?!![]:![]:!![],'where':_0x1e6371[_0x7f36('0x14')]?_0x1e6371[_0x7f36('0x14')][_0x7f36('0x16')]||null:null,'attributes':_0x1e6371[_0x7f36('0x14')]?_0x1e6371[_0x7f36('0x14')]['attributes']||null:null,'include':_0x1e6371['options']?_0x1e6371['options'][_0x7f36('0x17')]?_[_0x7f36('0x18')](_0x1e6371[_0x7f36('0x14')][_0x7f36('0x17')],function(_0x3cde7f){return{'model':db[_0x3cde7f[_0x7f36('0x19')]],'as':_0x3cde7f['as'],'attributes':_0x3cde7f[_0x7f36('0x1a')],'include':_0x3cde7f[_0x7f36('0x17')]?_[_0x7f36('0x18')](_0x3cde7f[_0x7f36('0x17')],function(_0x3d2414){return{'model':db[_0x3d2414[_0x7f36('0x19')]],'as':_0x3d2414['as'],'attributes':_0x3d2414[_0x7f36('0x1a')],'include':_0x3d2414[_0x7f36('0x17')]?_[_0x7f36('0x18')](_0x3d2414[_0x7f36('0x17')],function(_0x3f4570){return{'model':db[_0x3f4570[_0x7f36('0x19')]],'as':_0x3f4570['as'],'attributes':_0x3f4570['attributes']};}):[]};}):[]};}):[]:[]})[_0x7f36('0x7')](function(_0x47d7fe){logger['info']('ShowSound',_0x1e6371);logger[_0x7f36('0x1b')](_0x7f36('0x11'),_0x1e6371,JSON['stringify'](_0x47d7fe));_0x5aca2a(_0x47d7fe);})[_0x7f36('0x10')](function(_0x2a13d0){logger[_0x7f36('0xd')](_0x7f36('0x11'),_0x2a13d0['message'],_0x1e6371);_0x1100fb(_0x2a48a8[_0x7f36('0xd')](0x1f4,_0x2a13d0[_0x7f36('0xf')]));});});};