35082306d0122c5527203186fd4631ecea784b82
[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 _0xc24d=['../../config/environment','jayson/promise','http','request','then','Sound,\x20%s,\x20%s','request\x20sent','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','Sound','find','options','where','attributes','include','map','model','ShowSound','catch','lodash','util','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x5d16d8,_0x963852){var _0x33b302=function(_0x2b3c51){while(--_0x2b3c51){_0x5d16d8['push'](_0x5d16d8['shift']());}};_0x33b302(++_0x963852);}(_0xc24d,0x75));var _0xdc24=function(_0x1064bc,_0x206f12){_0x1064bc=_0x1064bc-0x0;var _0x5edc45=_0xc24d[_0x1064bc];return _0x5edc45;};'use strict';var _=require(_0xdc24('0x0'));var util=require(_0xdc24('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xdc24('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xdc24('0x3'))['db'];var utils=require(_0xdc24('0x4'));var logger=require(_0xdc24('0x5'))(_0xdc24('0x6'));var config=require(_0xdc24('0x7'));var jayson=require(_0xdc24('0x8'));var client=jayson['client'][_0xdc24('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2b587a,_0x5063d1,_0x33ef34){return new BPromise(function(_0x51f708,_0x3a8563){return client[_0xdc24('0xa')](_0x2b587a,_0x33ef34)[_0xdc24('0xb')](function(_0x2d50ab){logger['info'](_0xdc24('0xc'),_0x5063d1,_0xdc24('0xd'));logger[_0xdc24('0xe')](_0xdc24('0xf'),_0x5063d1,_0xdc24('0xd'),JSON[_0xdc24('0x10')](_0x2d50ab));if(_0x2d50ab['error']){if(_0x2d50ab[_0xdc24('0x11')]['code']===0x1f4){logger[_0xdc24('0x11')]('Sound,\x20%s,\x20%s',_0x5063d1,_0x2d50ab[_0xdc24('0x11')][_0xdc24('0x12')]);return _0x3a8563(_0x2d50ab[_0xdc24('0x11')][_0xdc24('0x12')]);}logger[_0xdc24('0x11')](_0xdc24('0xc'),_0x5063d1,_0x2d50ab['error'][_0xdc24('0x12')]);return _0x51f708(_0x2d50ab[_0xdc24('0x11')][_0xdc24('0x12')]);}else{logger[_0xdc24('0x13')](_0xdc24('0xc'),_0x5063d1,'request\x20sent');_0x51f708(_0x2d50ab[_0xdc24('0x14')][_0xdc24('0x12')]);}})['catch'](function(_0x525637){logger[_0xdc24('0x11')](_0xdc24('0xc'),_0x5063d1,_0x525637);_0x3a8563(_0x525637);});});}exports['ShowSound']=function(_0x5555e7){var _0x2d0e30=this;return new Promise(function(_0x115bee,_0x176170){return db[_0xdc24('0x15')][_0xdc24('0x16')]({'raw':_0x5555e7[_0xdc24('0x17')]?_0x5555e7['options']['raw']===undefined?!![]:![]:!![],'where':_0x5555e7[_0xdc24('0x17')]?_0x5555e7[_0xdc24('0x17')][_0xdc24('0x18')]||null:null,'attributes':_0x5555e7[_0xdc24('0x17')]?_0x5555e7[_0xdc24('0x17')][_0xdc24('0x19')]||null:null,'include':_0x5555e7['options']?_0x5555e7['options'][_0xdc24('0x1a')]?_[_0xdc24('0x1b')](_0x5555e7['options'][_0xdc24('0x1a')],function(_0x3b50c4){return{'model':db[_0x3b50c4[_0xdc24('0x1c')]],'as':_0x3b50c4['as'],'attributes':_0x3b50c4[_0xdc24('0x19')],'include':_0x3b50c4['include']?_[_0xdc24('0x1b')](_0x3b50c4['include'],function(_0x447f93){return{'model':db[_0x447f93['model']],'as':_0x447f93['as'],'attributes':_0x447f93[_0xdc24('0x19')],'include':_0x447f93['include']?_[_0xdc24('0x1b')](_0x447f93[_0xdc24('0x1a')],function(_0x26b216){return{'model':db[_0x26b216['model']],'as':_0x26b216['as'],'attributes':_0x26b216[_0xdc24('0x19')]};}):[]};}):[]};}):[]:[]})[_0xdc24('0xb')](function(_0x388396){logger[_0xdc24('0x13')](_0xdc24('0x1d'),_0x5555e7);logger[_0xdc24('0xe')](_0xdc24('0x1d'),_0x5555e7,JSON['stringify'](_0x388396));_0x115bee(_0x388396);})[_0xdc24('0x1e')](function(_0x30568e){logger[_0xdc24('0x11')](_0xdc24('0x1d'),_0x30568e[_0xdc24('0x12')],_0x5555e7);_0x176170(_0x2d0e30[_0xdc24('0x11')](0x1f4,_0x30568e[_0xdc24('0x12')]));});});};