c623849de0206b787cfde216834caaa847361adf
[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 _0x628f=['request','then','info','request\x20sent','debug','stringify','error','code','Sound,\x20%s,\x20%s','message','result','ShowSound','Sound','find','options','raw','where','attributes','include','map','model','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http'];(function(_0x487524,_0x156859){var _0x37a620=function(_0x13dc0b){while(--_0x13dc0b){_0x487524['push'](_0x487524['shift']());}};_0x37a620(++_0x156859);}(_0x628f,0x104));var _0xf628=function(_0x4a2fde,_0x190c2f){_0x4a2fde=_0x4a2fde-0x0;var _0x52ab47=_0x628f[_0x4a2fde];return _0x52ab47;};'use strict';var _=require(_0xf628('0x0'));var util=require('util');var moment=require(_0xf628('0x1'));var BPromise=require(_0xf628('0x2'));var rs=require(_0xf628('0x3'));var fs=require('fs');var Redis=require(_0xf628('0x4'));var db=require(_0xf628('0x5'))['db'];var utils=require(_0xf628('0x6'));var logger=require(_0xf628('0x7'))(_0xf628('0x8'));var config=require('../../config/environment');var jayson=require(_0xf628('0x9'));var client=jayson[_0xf628('0xa')][_0xf628('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x47f23a,_0x2b2771,_0x17cd48){return new BPromise(function(_0x643280,_0x2e74a2){return client[_0xf628('0xc')](_0x47f23a,_0x17cd48)[_0xf628('0xd')](function(_0x36a197){logger[_0xf628('0xe')]('Sound,\x20%s,\x20%s',_0x2b2771,_0xf628('0xf'));logger[_0xf628('0x10')]('Sound,\x20%s,\x20%s,\x20%s',_0x2b2771,_0xf628('0xf'),JSON[_0xf628('0x11')](_0x36a197));if(_0x36a197['error']){if(_0x36a197[_0xf628('0x12')][_0xf628('0x13')]===0x1f4){logger[_0xf628('0x12')](_0xf628('0x14'),_0x2b2771,_0x36a197['error']['message']);return _0x2e74a2(_0x36a197[_0xf628('0x12')][_0xf628('0x15')]);}logger[_0xf628('0x12')]('Sound,\x20%s,\x20%s',_0x2b2771,_0x36a197[_0xf628('0x12')]['message']);return _0x643280(_0x36a197['error'][_0xf628('0x15')]);}else{logger['info'](_0xf628('0x14'),_0x2b2771,_0xf628('0xf'));_0x643280(_0x36a197[_0xf628('0x16')]['message']);}})['catch'](function(_0x4e0f1c){logger[_0xf628('0x12')](_0xf628('0x14'),_0x2b2771,_0x4e0f1c);_0x2e74a2(_0x4e0f1c);});});}exports[_0xf628('0x17')]=function(_0x489ba1){var _0x25195c=this;return new Promise(function(_0x6f544c,_0x3d565e){return db[_0xf628('0x18')][_0xf628('0x19')]({'raw':_0x489ba1['options']?_0x489ba1[_0xf628('0x1a')][_0xf628('0x1b')]===undefined?!![]:![]:!![],'where':_0x489ba1['options']?_0x489ba1[_0xf628('0x1a')][_0xf628('0x1c')]||null:null,'attributes':_0x489ba1[_0xf628('0x1a')]?_0x489ba1[_0xf628('0x1a')][_0xf628('0x1d')]||null:null,'include':_0x489ba1['options']?_0x489ba1[_0xf628('0x1a')][_0xf628('0x1e')]?_[_0xf628('0x1f')](_0x489ba1['options'][_0xf628('0x1e')],function(_0x18bc3c){return{'model':db[_0x18bc3c[_0xf628('0x20')]],'as':_0x18bc3c['as'],'attributes':_0x18bc3c['attributes'],'include':_0x18bc3c[_0xf628('0x1e')]?_[_0xf628('0x1f')](_0x18bc3c[_0xf628('0x1e')],function(_0x398532){return{'model':db[_0x398532['model']],'as':_0x398532['as'],'attributes':_0x398532[_0xf628('0x1d')],'include':_0x398532['include']?_[_0xf628('0x1f')](_0x398532['include'],function(_0x4b02d7){return{'model':db[_0x4b02d7[_0xf628('0x20')]],'as':_0x4b02d7['as'],'attributes':_0x4b02d7[_0xf628('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xf628('0xd')](function(_0x5dfdde){logger[_0xf628('0xe')]('ShowSound',_0x489ba1);logger[_0xf628('0x10')](_0xf628('0x17'),_0x489ba1,JSON[_0xf628('0x11')](_0x5dfdde));_0x6f544c(_0x5dfdde);})[_0xf628('0x21')](function(_0x12807d){logger[_0xf628('0x12')](_0xf628('0x17'),_0x12807d['message'],_0x489ba1);_0x3d565e(_0x25195c[_0xf628('0x12')](0x1f4,_0x12807d['message']));});});};