Built motion from commit 994c64e1.|2.6.1
[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 _0xa4e8=['request','then','Sound,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','result','catch','ShowSound','Sound','find','options','raw','where','attributes','include','map','model','lodash','moment','bluebird','randomstring','../../mysqldb','rpc','client'];(function(_0x1abbb8,_0x3638d7){var _0x388130=function(_0x33bcc4){while(--_0x33bcc4){_0x1abbb8['push'](_0x1abbb8['shift']());}};_0x388130(++_0x3638d7);}(_0xa4e8,0xd1));var _0x8a4e=function(_0xcb6f41,_0x4759f1){_0xcb6f41=_0xcb6f41-0x0;var _0x21ced7=_0xa4e8[_0xcb6f41];return _0x21ced7;};'use strict';var _=require(_0x8a4e('0x0'));var util=require('util');var moment=require(_0x8a4e('0x1'));var BPromise=require(_0x8a4e('0x2'));var rs=require(_0x8a4e('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8a4e('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x8a4e('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x8a4e('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0x50e5fb,_0x4a2392,_0xf497f4){return new BPromise(function(_0xe0289c,_0x406338){return client[_0x8a4e('0x7')](_0x50e5fb,_0xf497f4)[_0x8a4e('0x8')](function(_0x5c3266){logger['info'](_0x8a4e('0x9'),_0x4a2392,_0x8a4e('0xa'));logger['debug']('Sound,\x20%s,\x20%s,\x20%s',_0x4a2392,_0x8a4e('0xa'),JSON[_0x8a4e('0xb')](_0x5c3266));if(_0x5c3266[_0x8a4e('0xc')]){if(_0x5c3266['error']['code']===0x1f4){logger['error'](_0x8a4e('0x9'),_0x4a2392,_0x5c3266[_0x8a4e('0xc')][_0x8a4e('0xd')]);return _0x406338(_0x5c3266['error'][_0x8a4e('0xd')]);}logger[_0x8a4e('0xc')](_0x8a4e('0x9'),_0x4a2392,_0x5c3266[_0x8a4e('0xc')]['message']);return _0xe0289c(_0x5c3266[_0x8a4e('0xc')][_0x8a4e('0xd')]);}else{logger[_0x8a4e('0xe')](_0x8a4e('0x9'),_0x4a2392,'request\x20sent');_0xe0289c(_0x5c3266[_0x8a4e('0xf')]['message']);}})[_0x8a4e('0x10')](function(_0x57e0cf){logger['error'](_0x8a4e('0x9'),_0x4a2392,_0x57e0cf);_0x406338(_0x57e0cf);});});}exports[_0x8a4e('0x11')]=function(_0x151f8c){var _0x5407ee=this;return new Promise(function(_0x459607,_0x2ff9bd){return db[_0x8a4e('0x12')][_0x8a4e('0x13')]({'raw':_0x151f8c['options']?_0x151f8c[_0x8a4e('0x14')][_0x8a4e('0x15')]===undefined?!![]:![]:!![],'where':_0x151f8c['options']?_0x151f8c[_0x8a4e('0x14')][_0x8a4e('0x16')]||null:null,'attributes':_0x151f8c[_0x8a4e('0x14')]?_0x151f8c[_0x8a4e('0x14')][_0x8a4e('0x17')]||null:null,'include':_0x151f8c[_0x8a4e('0x14')]?_0x151f8c[_0x8a4e('0x14')][_0x8a4e('0x18')]?_[_0x8a4e('0x19')](_0x151f8c[_0x8a4e('0x14')][_0x8a4e('0x18')],function(_0x356936){return{'model':db[_0x356936[_0x8a4e('0x1a')]],'as':_0x356936['as'],'attributes':_0x356936[_0x8a4e('0x17')],'include':_0x356936[_0x8a4e('0x18')]?_[_0x8a4e('0x19')](_0x356936[_0x8a4e('0x18')],function(_0xc41163){return{'model':db[_0xc41163[_0x8a4e('0x1a')]],'as':_0xc41163['as'],'attributes':_0xc41163['attributes'],'include':_0xc41163[_0x8a4e('0x18')]?_[_0x8a4e('0x19')](_0xc41163[_0x8a4e('0x18')],function(_0x226951){return{'model':db[_0x226951['model']],'as':_0x226951['as'],'attributes':_0x226951[_0x8a4e('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x52652c){logger['info'](_0x8a4e('0x11'),_0x151f8c);logger['debug'](_0x8a4e('0x11'),_0x151f8c,JSON['stringify'](_0x52652c));_0x459607(_0x52652c);})[_0x8a4e('0x10')](function(_0x2d0488){logger[_0x8a4e('0xc')](_0x8a4e('0x11'),_0x2d0488[_0x8a4e('0xd')],_0x151f8c);_0x2ff9bd(_0x5407ee['error'](0x1f4,_0x2d0488[_0x8a4e('0xd')]));});});};