c82c65cdfa911e139b4a12634d53436da1187aad
[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 _0x6fc9=['options','raw','where','include','map','model','attributes','ShowSound','lodash','moment','randomstring','ioredis','../../config/utils','../../config/logger','http','request','then','info','request\x20sent','debug','error','code','Sound,\x20%s,\x20%s','message','catch','Sound','find'];(function(_0x2d323b,_0x519fa7){var _0x192300=function(_0xf02f07){while(--_0xf02f07){_0x2d323b['push'](_0x2d323b['shift']());}};_0x192300(++_0x519fa7);}(_0x6fc9,0x182));var _0x96fc=function(_0x44f19a,_0x2219d0){_0x44f19a=_0x44f19a-0x0;var _0x3d448e=_0x6fc9[_0x44f19a];return _0x3d448e;};'use strict';var _=require(_0x96fc('0x0'));var util=require('util');var moment=require(_0x96fc('0x1'));var BPromise=require('bluebird');var rs=require(_0x96fc('0x2'));var fs=require('fs');var Redis=require(_0x96fc('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x96fc('0x4'));var logger=require(_0x96fc('0x5'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x96fc('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x48051a,_0x5409aa,_0x3b8f3a){return new BPromise(function(_0x3946ab,_0x5e907){return client[_0x96fc('0x7')](_0x48051a,_0x3b8f3a)[_0x96fc('0x8')](function(_0x434f43){logger[_0x96fc('0x9')]('Sound,\x20%s,\x20%s',_0x5409aa,_0x96fc('0xa'));logger[_0x96fc('0xb')]('Sound,\x20%s,\x20%s,\x20%s',_0x5409aa,'request\x20sent',JSON['stringify'](_0x434f43));if(_0x434f43[_0x96fc('0xc')]){if(_0x434f43['error'][_0x96fc('0xd')]===0x1f4){logger[_0x96fc('0xc')](_0x96fc('0xe'),_0x5409aa,_0x434f43[_0x96fc('0xc')]['message']);return _0x5e907(_0x434f43['error']['message']);}logger[_0x96fc('0xc')]('Sound,\x20%s,\x20%s',_0x5409aa,_0x434f43[_0x96fc('0xc')]['message']);return _0x3946ab(_0x434f43[_0x96fc('0xc')][_0x96fc('0xf')]);}else{logger[_0x96fc('0x9')](_0x96fc('0xe'),_0x5409aa,_0x96fc('0xa'));_0x3946ab(_0x434f43['result'][_0x96fc('0xf')]);}})[_0x96fc('0x10')](function(_0x2694a8){logger[_0x96fc('0xc')](_0x96fc('0xe'),_0x5409aa,_0x2694a8);_0x5e907(_0x2694a8);});});}exports['ShowSound']=function(_0x6f7b93){var _0x4b01b0=this;return new Promise(function(_0xb14440,_0xf47378){return db[_0x96fc('0x11')][_0x96fc('0x12')]({'raw':_0x6f7b93[_0x96fc('0x13')]?_0x6f7b93['options'][_0x96fc('0x14')]===undefined?!![]:![]:!![],'where':_0x6f7b93[_0x96fc('0x13')]?_0x6f7b93[_0x96fc('0x13')][_0x96fc('0x15')]||null:null,'attributes':_0x6f7b93['options']?_0x6f7b93[_0x96fc('0x13')]['attributes']||null:null,'include':_0x6f7b93[_0x96fc('0x13')]?_0x6f7b93[_0x96fc('0x13')][_0x96fc('0x16')]?_[_0x96fc('0x17')](_0x6f7b93[_0x96fc('0x13')][_0x96fc('0x16')],function(_0x3bfb63){return{'model':db[_0x3bfb63['model']],'as':_0x3bfb63['as'],'attributes':_0x3bfb63['attributes'],'include':_0x3bfb63['include']?_['map'](_0x3bfb63['include'],function(_0x5179f7){return{'model':db[_0x5179f7[_0x96fc('0x18')]],'as':_0x5179f7['as'],'attributes':_0x5179f7['attributes'],'include':_0x5179f7[_0x96fc('0x16')]?_[_0x96fc('0x17')](_0x5179f7[_0x96fc('0x16')],function(_0x120f2b){return{'model':db[_0x120f2b[_0x96fc('0x18')]],'as':_0x120f2b['as'],'attributes':_0x120f2b[_0x96fc('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x59fccb){logger['info'](_0x96fc('0x1a'),_0x6f7b93);logger[_0x96fc('0xb')](_0x96fc('0x1a'),_0x6f7b93,JSON['stringify'](_0x59fccb));_0xb14440(_0x59fccb);})[_0x96fc('0x10')](function(_0x1f36d6){logger[_0x96fc('0xc')](_0x96fc('0x1a'),_0x1f36d6['message'],_0x6f7b93);_0xf47378(_0x4b01b0['error'](0x1f4,_0x1f36d6[_0x96fc('0xf')]));});});};