0c9fc919300498ed33ac72ae005aca95420519fd
[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 _0x4431=['bluebird','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','stringify','error','Sound,\x20%s,\x20%s','message','catch','ShowSound','Sound','options','raw','where','attributes','include','map','model','then','moment'];(function(_0x5ca353,_0x21eb37){var _0x4f2fe5=function(_0x14cd1b){while(--_0x14cd1b){_0x5ca353['push'](_0x5ca353['shift']());}};_0x4f2fe5(++_0x21eb37);}(_0x4431,0x8b));var _0x1443=function(_0x537cec,_0x3a2b28){_0x537cec=_0x537cec-0x0;var _0x35b884=_0x4431[_0x537cec];return _0x35b884;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x1443('0x0'));var BPromise=require(_0x1443('0x1'));var rs=require(_0x1443('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x1443('0x3'))(_0x1443('0x4'));var config=require(_0x1443('0x5'));var jayson=require(_0x1443('0x6'));var client=jayson[_0x1443('0x7')][_0x1443('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2ee982,_0x54554c,_0x231a37){return new BPromise(function(_0x3632b1,_0x372799){return client[_0x1443('0x9')](_0x2ee982,_0x231a37)['then'](function(_0x46083c){logger[_0x1443('0xa')]('Sound,\x20%s,\x20%s',_0x54554c,_0x1443('0xb'));logger[_0x1443('0xc')]('Sound,\x20%s,\x20%s,\x20%s',_0x54554c,_0x1443('0xb'),JSON[_0x1443('0xd')](_0x46083c));if(_0x46083c[_0x1443('0xe')]){if(_0x46083c[_0x1443('0xe')]['code']===0x1f4){logger['error'](_0x1443('0xf'),_0x54554c,_0x46083c[_0x1443('0xe')]['message']);return _0x372799(_0x46083c['error'][_0x1443('0x10')]);}logger[_0x1443('0xe')]('Sound,\x20%s,\x20%s',_0x54554c,_0x46083c[_0x1443('0xe')][_0x1443('0x10')]);return _0x3632b1(_0x46083c[_0x1443('0xe')]['message']);}else{logger[_0x1443('0xa')]('Sound,\x20%s,\x20%s',_0x54554c,_0x1443('0xb'));_0x3632b1(_0x46083c['result'][_0x1443('0x10')]);}})[_0x1443('0x11')](function(_0x350252){logger['error'](_0x1443('0xf'),_0x54554c,_0x350252);_0x372799(_0x350252);});});}exports[_0x1443('0x12')]=function(_0x4df358){var _0x3311fc=this;return new Promise(function(_0x40bb89,_0x12e6f4){return db[_0x1443('0x13')]['find']({'raw':_0x4df358[_0x1443('0x14')]?_0x4df358[_0x1443('0x14')][_0x1443('0x15')]===undefined?!![]:![]:!![],'where':_0x4df358['options']?_0x4df358[_0x1443('0x14')][_0x1443('0x16')]||null:null,'attributes':_0x4df358[_0x1443('0x14')]?_0x4df358['options'][_0x1443('0x17')]||null:null,'include':_0x4df358[_0x1443('0x14')]?_0x4df358[_0x1443('0x14')][_0x1443('0x18')]?_[_0x1443('0x19')](_0x4df358[_0x1443('0x14')]['include'],function(_0x2727f9){return{'model':db[_0x2727f9['model']],'as':_0x2727f9['as'],'attributes':_0x2727f9[_0x1443('0x17')],'include':_0x2727f9[_0x1443('0x18')]?_[_0x1443('0x19')](_0x2727f9[_0x1443('0x18')],function(_0x4f6176){return{'model':db[_0x4f6176[_0x1443('0x1a')]],'as':_0x4f6176['as'],'attributes':_0x4f6176['attributes'],'include':_0x4f6176[_0x1443('0x18')]?_[_0x1443('0x19')](_0x4f6176[_0x1443('0x18')],function(_0x490d93){return{'model':db[_0x490d93['model']],'as':_0x490d93['as'],'attributes':_0x490d93[_0x1443('0x17')]};}):[]};}):[]};}):[]:[]})[_0x1443('0x1b')](function(_0x48185c){logger[_0x1443('0xa')](_0x1443('0x12'),_0x4df358);logger[_0x1443('0xc')](_0x1443('0x12'),_0x4df358,JSON[_0x1443('0xd')](_0x48185c));_0x40bb89(_0x48185c);})['catch'](function(_0x37bfa6){logger[_0x1443('0xe')]('ShowSound',_0x37bfa6[_0x1443('0x10')],_0x4df358);_0x12e6f4(_0x3311fc['error'](0x1f4,_0x37bfa6[_0x1443('0x10')]));});});};