Built motion from commit 9d0783e6.|2.6.13
[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 _0x48f7=['request','Sound,\x20%s,\x20%s','request\x20sent','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','ShowSound','Sound','options','where','attributes','include','map','model','then','info','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http'];(function(_0xe4b973,_0x527de2){var _0x5ad4eb=function(_0x459ce3){while(--_0x459ce3){_0xe4b973['push'](_0xe4b973['shift']());}};_0x5ad4eb(++_0x527de2);}(_0x48f7,0x174));var _0x748f=function(_0xf3c72f,_0x2e992e){_0xf3c72f=_0xf3c72f-0x0;var _0x472c34=_0x48f7[_0xf3c72f];return _0x472c34;};'use strict';var _=require(_0x748f('0x0'));var util=require(_0x748f('0x1'));var moment=require(_0x748f('0x2'));var BPromise=require(_0x748f('0x3'));var rs=require(_0x748f('0x4'));var fs=require('fs');var Redis=require(_0x748f('0x5'));var db=require(_0x748f('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x748f('0x7'))(_0x748f('0x8'));var config=require(_0x748f('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x748f('0xa')][_0x748f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x238949,_0x5d06e1,_0x292c28){return new BPromise(function(_0x534ec6,_0x32f7f8){return client[_0x748f('0xc')](_0x238949,_0x292c28)['then'](function(_0x3d0de5){logger['info'](_0x748f('0xd'),_0x5d06e1,_0x748f('0xe'));logger[_0x748f('0xf')](_0x748f('0x10'),_0x5d06e1,_0x748f('0xe'),JSON[_0x748f('0x11')](_0x3d0de5));if(_0x3d0de5['error']){if(_0x3d0de5[_0x748f('0x12')]['code']===0x1f4){logger[_0x748f('0x12')]('Sound,\x20%s,\x20%s',_0x5d06e1,_0x3d0de5['error'][_0x748f('0x13')]);return _0x32f7f8(_0x3d0de5[_0x748f('0x12')]['message']);}logger[_0x748f('0x12')](_0x748f('0xd'),_0x5d06e1,_0x3d0de5[_0x748f('0x12')]['message']);return _0x534ec6(_0x3d0de5[_0x748f('0x12')][_0x748f('0x13')]);}else{logger['info']('Sound,\x20%s,\x20%s',_0x5d06e1,_0x748f('0xe'));_0x534ec6(_0x3d0de5[_0x748f('0x14')][_0x748f('0x13')]);}})[_0x748f('0x15')](function(_0x549efd){logger[_0x748f('0x12')]('Sound,\x20%s,\x20%s',_0x5d06e1,_0x549efd);_0x32f7f8(_0x549efd);});});}exports[_0x748f('0x16')]=function(_0x15eff6){var _0x14a166=this;return new Promise(function(_0x8129c7,_0x2d354b){return db[_0x748f('0x17')]['find']({'raw':_0x15eff6[_0x748f('0x18')]?_0x15eff6[_0x748f('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x15eff6[_0x748f('0x18')]?_0x15eff6[_0x748f('0x18')][_0x748f('0x19')]||null:null,'attributes':_0x15eff6[_0x748f('0x18')]?_0x15eff6[_0x748f('0x18')][_0x748f('0x1a')]||null:null,'include':_0x15eff6[_0x748f('0x18')]?_0x15eff6[_0x748f('0x18')][_0x748f('0x1b')]?_[_0x748f('0x1c')](_0x15eff6[_0x748f('0x18')]['include'],function(_0x3ff10f){return{'model':db[_0x3ff10f['model']],'as':_0x3ff10f['as'],'attributes':_0x3ff10f[_0x748f('0x1a')],'include':_0x3ff10f[_0x748f('0x1b')]?_[_0x748f('0x1c')](_0x3ff10f[_0x748f('0x1b')],function(_0x148a0d){return{'model':db[_0x148a0d[_0x748f('0x1d')]],'as':_0x148a0d['as'],'attributes':_0x148a0d[_0x748f('0x1a')],'include':_0x148a0d[_0x748f('0x1b')]?_[_0x748f('0x1c')](_0x148a0d[_0x748f('0x1b')],function(_0x33989d){return{'model':db[_0x33989d[_0x748f('0x1d')]],'as':_0x33989d['as'],'attributes':_0x33989d['attributes']};}):[]};}):[]};}):[]:[]})[_0x748f('0x1e')](function(_0x49a3a2){logger[_0x748f('0x1f')](_0x748f('0x16'),_0x15eff6);logger[_0x748f('0xf')](_0x748f('0x16'),_0x15eff6,JSON[_0x748f('0x11')](_0x49a3a2));_0x8129c7(_0x49a3a2);})['catch'](function(_0x1e60a1){logger[_0x748f('0x12')](_0x748f('0x16'),_0x1e60a1['message'],_0x15eff6);_0x2d354b(_0x14a166['error'](0x1f4,_0x1e60a1[_0x748f('0x13')]));});});};