Built motion from commit 00bf23f6.|2.6.16
[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 _0xdbfb=['debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','find','options','raw','where','attributes','include','map','model','ShowSound','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','Sound,\x20%s,\x20%s','request\x20sent'];(function(_0x4c6c97,_0x243a44){var _0x3f6ca7=function(_0x54e6b7){while(--_0x54e6b7){_0x4c6c97['push'](_0x4c6c97['shift']());}};_0x3f6ca7(++_0x243a44);}(_0xdbfb,0x122));var _0xbdbf=function(_0x39840e,_0x52683a){_0x39840e=_0x39840e-0x0;var _0xc179cf=_0xdbfb[_0x39840e];return _0xc179cf;};'use strict';var _=require(_0xbdbf('0x0'));var util=require(_0xbdbf('0x1'));var moment=require(_0xbdbf('0x2'));var BPromise=require(_0xbdbf('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbdbf('0x4'));var db=require(_0xbdbf('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xbdbf('0x6'))(_0xbdbf('0x7'));var config=require(_0xbdbf('0x8'));var jayson=require(_0xbdbf('0x9'));var client=jayson[_0xbdbf('0xa')][_0xbdbf('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3e52c2,_0x3e1f53,_0x31c9d0){return new BPromise(function(_0x6ab774,_0x4927ce){return client[_0xbdbf('0xc')](_0x3e52c2,_0x31c9d0)[_0xbdbf('0xd')](function(_0x2dc3c7){logger['info'](_0xbdbf('0xe'),_0x3e1f53,_0xbdbf('0xf'));logger[_0xbdbf('0x10')](_0xbdbf('0x11'),_0x3e1f53,_0xbdbf('0xf'),JSON[_0xbdbf('0x12')](_0x2dc3c7));if(_0x2dc3c7['error']){if(_0x2dc3c7[_0xbdbf('0x13')][_0xbdbf('0x14')]===0x1f4){logger[_0xbdbf('0x13')]('Sound,\x20%s,\x20%s',_0x3e1f53,_0x2dc3c7['error'][_0xbdbf('0x15')]);return _0x4927ce(_0x2dc3c7[_0xbdbf('0x13')]['message']);}logger['error']('Sound,\x20%s,\x20%s',_0x3e1f53,_0x2dc3c7['error'][_0xbdbf('0x15')]);return _0x6ab774(_0x2dc3c7[_0xbdbf('0x13')][_0xbdbf('0x15')]);}else{logger[_0xbdbf('0x16')](_0xbdbf('0xe'),_0x3e1f53,_0xbdbf('0xf'));_0x6ab774(_0x2dc3c7[_0xbdbf('0x17')][_0xbdbf('0x15')]);}})[_0xbdbf('0x18')](function(_0x97b7b8){logger[_0xbdbf('0x13')](_0xbdbf('0xe'),_0x3e1f53,_0x97b7b8);_0x4927ce(_0x97b7b8);});});}exports['ShowSound']=function(_0x5f107f){var _0x51ff4a=this;return new Promise(function(_0x5f1dc9,_0x36d953){return db['Sound'][_0xbdbf('0x19')]({'raw':_0x5f107f[_0xbdbf('0x1a')]?_0x5f107f[_0xbdbf('0x1a')][_0xbdbf('0x1b')]===undefined?!![]:![]:!![],'where':_0x5f107f[_0xbdbf('0x1a')]?_0x5f107f[_0xbdbf('0x1a')][_0xbdbf('0x1c')]||null:null,'attributes':_0x5f107f[_0xbdbf('0x1a')]?_0x5f107f['options'][_0xbdbf('0x1d')]||null:null,'include':_0x5f107f[_0xbdbf('0x1a')]?_0x5f107f['options'][_0xbdbf('0x1e')]?_[_0xbdbf('0x1f')](_0x5f107f[_0xbdbf('0x1a')]['include'],function(_0x29b024){return{'model':db[_0x29b024[_0xbdbf('0x20')]],'as':_0x29b024['as'],'attributes':_0x29b024[_0xbdbf('0x1d')],'include':_0x29b024[_0xbdbf('0x1e')]?_['map'](_0x29b024['include'],function(_0x382522){return{'model':db[_0x382522[_0xbdbf('0x20')]],'as':_0x382522['as'],'attributes':_0x382522['attributes'],'include':_0x382522[_0xbdbf('0x1e')]?_[_0xbdbf('0x1f')](_0x382522[_0xbdbf('0x1e')],function(_0x1938b4){return{'model':db[_0x1938b4['model']],'as':_0x1938b4['as'],'attributes':_0x1938b4[_0xbdbf('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2f7198){logger[_0xbdbf('0x16')](_0xbdbf('0x21'),_0x5f107f);logger['debug'](_0xbdbf('0x21'),_0x5f107f,JSON['stringify'](_0x2f7198));_0x5f1dc9(_0x2f7198);})[_0xbdbf('0x18')](function(_0x5bd1e9){logger[_0xbdbf('0x13')](_0xbdbf('0x21'),_0x5bd1e9[_0xbdbf('0x15')],_0x5f107f);_0x36d953(_0x51ff4a[_0xbdbf('0x13')](0x1f4,_0x5bd1e9['message']));});});};