Built motion from commit 3e059bc2.|2.5.32
[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 _0x35a5=['message','result','catch','Sound','find','options','attributes','model','include','map','then','ShowSound','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','Sound,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x35a5,0x174));var _0x535a=function(_0xbd896c,_0x3380f7){_0xbd896c=_0xbd896c-0x0;var _0x5d3296=_0x35a5[_0xbd896c];return _0x5d3296;};'use strict';var _=require('lodash');var util=require(_0x535a('0x0'));var moment=require('moment');var BPromise=require(_0x535a('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x535a('0x2'));var db=require(_0x535a('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x535a('0x4'))(_0x535a('0x5'));var config=require(_0x535a('0x6'));var jayson=require(_0x535a('0x7'));var client=jayson[_0x535a('0x8')][_0x535a('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x33cd7a,_0x14f160,_0x498467){return new BPromise(function(_0x19f1e7,_0x1a509b){return client[_0x535a('0xa')](_0x33cd7a,_0x498467)['then'](function(_0x53071b){logger[_0x535a('0xb')](_0x535a('0xc'),_0x14f160,_0x535a('0xd'));logger[_0x535a('0xe')]('Sound,\x20%s,\x20%s,\x20%s',_0x14f160,'request\x20sent',JSON[_0x535a('0xf')](_0x53071b));if(_0x53071b['error']){if(_0x53071b['error'][_0x535a('0x10')]===0x1f4){logger['error'](_0x535a('0xc'),_0x14f160,_0x53071b[_0x535a('0x11')][_0x535a('0x12')]);return _0x1a509b(_0x53071b['error'][_0x535a('0x12')]);}logger[_0x535a('0x11')](_0x535a('0xc'),_0x14f160,_0x53071b['error'][_0x535a('0x12')]);return _0x19f1e7(_0x53071b[_0x535a('0x11')]['message']);}else{logger[_0x535a('0xb')]('Sound,\x20%s,\x20%s',_0x14f160,'request\x20sent');_0x19f1e7(_0x53071b[_0x535a('0x13')][_0x535a('0x12')]);}})[_0x535a('0x14')](function(_0x3e8f60){logger[_0x535a('0x11')]('Sound,\x20%s,\x20%s',_0x14f160,_0x3e8f60);_0x1a509b(_0x3e8f60);});});}exports['ShowSound']=function(_0x184300){var _0x3909be=this;return new Promise(function(_0x4ab050,_0x2f8a3a){return db[_0x535a('0x15')][_0x535a('0x16')]({'raw':_0x184300[_0x535a('0x17')]?_0x184300[_0x535a('0x17')]['raw']===undefined?!![]:![]:!![],'where':_0x184300[_0x535a('0x17')]?_0x184300[_0x535a('0x17')]['where']||null:null,'attributes':_0x184300[_0x535a('0x17')]?_0x184300['options'][_0x535a('0x18')]||null:null,'include':_0x184300[_0x535a('0x17')]?_0x184300[_0x535a('0x17')]['include']?_['map'](_0x184300[_0x535a('0x17')]['include'],function(_0x56fa06){return{'model':db[_0x56fa06[_0x535a('0x19')]],'as':_0x56fa06['as'],'attributes':_0x56fa06[_0x535a('0x18')],'include':_0x56fa06[_0x535a('0x1a')]?_[_0x535a('0x1b')](_0x56fa06[_0x535a('0x1a')],function(_0x517135){return{'model':db[_0x517135['model']],'as':_0x517135['as'],'attributes':_0x517135[_0x535a('0x18')],'include':_0x517135['include']?_['map'](_0x517135['include'],function(_0x1c7be4){return{'model':db[_0x1c7be4[_0x535a('0x19')]],'as':_0x1c7be4['as'],'attributes':_0x1c7be4['attributes']};}):[]};}):[]};}):[]:[]})[_0x535a('0x1c')](function(_0x58cce7){logger[_0x535a('0xb')]('ShowSound',_0x184300);logger[_0x535a('0xe')](_0x535a('0x1d'),_0x184300,JSON[_0x535a('0xf')](_0x58cce7));_0x4ab050(_0x58cce7);})[_0x535a('0x14')](function(_0x36abe6){logger[_0x535a('0x11')](_0x535a('0x1d'),_0x36abe6[_0x535a('0x12')],_0x184300);_0x2f8a3a(_0x3909be[_0x535a('0x11')](0x1f4,_0x36abe6[_0x535a('0x12')]));});});};