c4d12e0d1fc50cacf7aedc616deb4767a3d76eb7
[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 _0x0c19=['options','where','attributes','include','map','model','then','ShowSound','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','info','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','code','Sound,\x20%s,\x20%s','message','request\x20sent','catch','Sound','find'];(function(_0xf8ba2a,_0x356ed5){var _0x6ba8a2=function(_0x536d90){while(--_0x536d90){_0xf8ba2a['push'](_0xf8ba2a['shift']());}};_0x6ba8a2(++_0x356ed5);}(_0x0c19,0x168));var _0x90c1=function(_0x526916,_0x48fef0){_0x526916=_0x526916-0x0;var _0x1c23c5=_0x0c19[_0x526916];return _0x1c23c5;};'use strict';var _=require(_0x90c1('0x0'));var util=require(_0x90c1('0x1'));var moment=require(_0x90c1('0x2'));var BPromise=require('bluebird');var rs=require(_0x90c1('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x90c1('0x4'))['db'];var utils=require(_0x90c1('0x5'));var logger=require(_0x90c1('0x6'))(_0x90c1('0x7'));var config=require(_0x90c1('0x8'));var jayson=require(_0x90c1('0x9'));var client=jayson[_0x90c1('0xa')][_0x90c1('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x385df5,_0x494834,_0x497faa){return new BPromise(function(_0x4975bb,_0x186a94){return client['request'](_0x385df5,_0x497faa)['then'](function(_0x5f4e85){logger[_0x90c1('0xc')]('Sound,\x20%s,\x20%s',_0x494834,'request\x20sent');logger[_0x90c1('0xd')](_0x90c1('0xe'),_0x494834,'request\x20sent',JSON[_0x90c1('0xf')](_0x5f4e85));if(_0x5f4e85[_0x90c1('0x10')]){if(_0x5f4e85[_0x90c1('0x10')][_0x90c1('0x11')]===0x1f4){logger[_0x90c1('0x10')](_0x90c1('0x12'),_0x494834,_0x5f4e85['error'][_0x90c1('0x13')]);return _0x186a94(_0x5f4e85[_0x90c1('0x10')][_0x90c1('0x13')]);}logger[_0x90c1('0x10')]('Sound,\x20%s,\x20%s',_0x494834,_0x5f4e85['error'][_0x90c1('0x13')]);return _0x4975bb(_0x5f4e85['error'][_0x90c1('0x13')]);}else{logger[_0x90c1('0xc')](_0x90c1('0x12'),_0x494834,_0x90c1('0x14'));_0x4975bb(_0x5f4e85['result'][_0x90c1('0x13')]);}})[_0x90c1('0x15')](function(_0x3b31a4){logger[_0x90c1('0x10')](_0x90c1('0x12'),_0x494834,_0x3b31a4);_0x186a94(_0x3b31a4);});});}exports['ShowSound']=function(_0x1570dc){var _0x12e5f5=this;return new Promise(function(_0x59fe7f,_0x22bc43){return db[_0x90c1('0x16')][_0x90c1('0x17')]({'raw':_0x1570dc[_0x90c1('0x18')]?_0x1570dc[_0x90c1('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x1570dc[_0x90c1('0x18')]?_0x1570dc[_0x90c1('0x18')][_0x90c1('0x19')]||null:null,'attributes':_0x1570dc['options']?_0x1570dc['options'][_0x90c1('0x1a')]||null:null,'include':_0x1570dc[_0x90c1('0x18')]?_0x1570dc[_0x90c1('0x18')][_0x90c1('0x1b')]?_[_0x90c1('0x1c')](_0x1570dc[_0x90c1('0x18')][_0x90c1('0x1b')],function(_0x58b229){return{'model':db[_0x58b229['model']],'as':_0x58b229['as'],'attributes':_0x58b229[_0x90c1('0x1a')],'include':_0x58b229[_0x90c1('0x1b')]?_[_0x90c1('0x1c')](_0x58b229['include'],function(_0x1162ec){return{'model':db[_0x1162ec['model']],'as':_0x1162ec['as'],'attributes':_0x1162ec[_0x90c1('0x1a')],'include':_0x1162ec[_0x90c1('0x1b')]?_['map'](_0x1162ec['include'],function(_0x5bb169){return{'model':db[_0x5bb169[_0x90c1('0x1d')]],'as':_0x5bb169['as'],'attributes':_0x5bb169[_0x90c1('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x90c1('0x1e')](function(_0x124be3){logger[_0x90c1('0xc')](_0x90c1('0x1f'),_0x1570dc);logger[_0x90c1('0xd')](_0x90c1('0x1f'),_0x1570dc,JSON[_0x90c1('0xf')](_0x124be3));_0x59fe7f(_0x124be3);})[_0x90c1('0x15')](function(_0x47923e){logger[_0x90c1('0x10')](_0x90c1('0x1f'),_0x47923e[_0x90c1('0x13')],_0x1570dc);_0x22bc43(_0x12e5f5['error'](0x1f4,_0x47923e[_0x90c1('0x13')]));});});};