3bcdf88dbf7fd1ad94b66fc555ee466caeb276dd
[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 _0xf65f=['Sound','find','options','raw','where','attributes','include','map','model','ShowSound','catch','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','http','request','then','info','Sound,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message'];(function(_0x19ef32,_0x3b78ff){var _0x20034e=function(_0x3eb2d9){while(--_0x3eb2d9){_0x19ef32['push'](_0x19ef32['shift']());}};_0x20034e(++_0x3b78ff);}(_0xf65f,0x119));var _0xff65=function(_0x2f8000,_0x37c02b){_0x2f8000=_0x2f8000-0x0;var _0x25cfee=_0xf65f[_0x2f8000];return _0x25cfee;};'use strict';var _=require(_0xff65('0x0'));var util=require(_0xff65('0x1'));var moment=require('moment');var BPromise=require(_0xff65('0x2'));var rs=require(_0xff65('0x3'));var fs=require('fs');var Redis=require(_0xff65('0x4'));var db=require(_0xff65('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xff65('0x6'))(_0xff65('0x7'));var config=require('../../config/environment');var jayson=require(_0xff65('0x8'));var client=jayson['client'][_0xff65('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2905f8,_0x4b6836,_0xdf931a){return new BPromise(function(_0x2af5a7,_0x3db7e8){return client[_0xff65('0xa')](_0x2905f8,_0xdf931a)[_0xff65('0xb')](function(_0x26c590){logger[_0xff65('0xc')](_0xff65('0xd'),_0x4b6836,_0xff65('0xe'));logger[_0xff65('0xf')]('Sound,\x20%s,\x20%s,\x20%s',_0x4b6836,_0xff65('0xe'),JSON[_0xff65('0x10')](_0x26c590));if(_0x26c590[_0xff65('0x11')]){if(_0x26c590[_0xff65('0x11')]['code']===0x1f4){logger[_0xff65('0x11')]('Sound,\x20%s,\x20%s',_0x4b6836,_0x26c590[_0xff65('0x11')][_0xff65('0x12')]);return _0x3db7e8(_0x26c590[_0xff65('0x11')][_0xff65('0x12')]);}logger['error']('Sound,\x20%s,\x20%s',_0x4b6836,_0x26c590[_0xff65('0x11')][_0xff65('0x12')]);return _0x2af5a7(_0x26c590[_0xff65('0x11')]['message']);}else{logger[_0xff65('0xc')](_0xff65('0xd'),_0x4b6836,'request\x20sent');_0x2af5a7(_0x26c590['result'][_0xff65('0x12')]);}})['catch'](function(_0x12e9ac){logger['error']('Sound,\x20%s,\x20%s',_0x4b6836,_0x12e9ac);_0x3db7e8(_0x12e9ac);});});}exports['ShowSound']=function(_0x47bae3){var _0x1537c=this;return new Promise(function(_0x161c45,_0x25703a){return db[_0xff65('0x13')][_0xff65('0x14')]({'raw':_0x47bae3[_0xff65('0x15')]?_0x47bae3[_0xff65('0x15')][_0xff65('0x16')]===undefined?!![]:![]:!![],'where':_0x47bae3[_0xff65('0x15')]?_0x47bae3[_0xff65('0x15')][_0xff65('0x17')]||null:null,'attributes':_0x47bae3[_0xff65('0x15')]?_0x47bae3['options'][_0xff65('0x18')]||null:null,'include':_0x47bae3[_0xff65('0x15')]?_0x47bae3['options'][_0xff65('0x19')]?_[_0xff65('0x1a')](_0x47bae3[_0xff65('0x15')][_0xff65('0x19')],function(_0x1ca85d){return{'model':db[_0x1ca85d[_0xff65('0x1b')]],'as':_0x1ca85d['as'],'attributes':_0x1ca85d[_0xff65('0x18')],'include':_0x1ca85d[_0xff65('0x19')]?_[_0xff65('0x1a')](_0x1ca85d['include'],function(_0x317d15){return{'model':db[_0x317d15[_0xff65('0x1b')]],'as':_0x317d15['as'],'attributes':_0x317d15[_0xff65('0x18')],'include':_0x317d15[_0xff65('0x19')]?_[_0xff65('0x1a')](_0x317d15[_0xff65('0x19')],function(_0x4cf339){return{'model':db[_0x4cf339[_0xff65('0x1b')]],'as':_0x4cf339['as'],'attributes':_0x4cf339[_0xff65('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xbcb914){logger['info'](_0xff65('0x1c'),_0x47bae3);logger[_0xff65('0xf')](_0xff65('0x1c'),_0x47bae3,JSON['stringify'](_0xbcb914));_0x161c45(_0xbcb914);})[_0xff65('0x1d')](function(_0x30e359){logger[_0xff65('0x11')](_0xff65('0x1c'),_0x30e359['message'],_0x47bae3);_0x25703a(_0x1537c[_0xff65('0x11')](0x1f4,_0x30e359[_0xff65('0x12')]));});});};