bdb6d943777b70f89584780f4bbf5d17bf7cc8c3
[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 _0xe411=['Sound,\x20%s,\x20%s','message','result','catch','ShowSound','Sound','find','options','raw','where','map','include','model','attributes','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','request\x20sent','stringify','error','code'];(function(_0xac151d,_0x4ea1d2){var _0x111dba=function(_0x13d7f4){while(--_0x13d7f4){_0xac151d['push'](_0xac151d['shift']());}};_0x111dba(++_0x4ea1d2);}(_0xe411,0x11f));var _0x1e41=function(_0x99952f,_0x58a3ea){_0x99952f=_0x99952f-0x0;var _0x5701c6=_0xe411[_0x99952f];return _0x5701c6;};'use strict';var _=require(_0x1e41('0x0'));var util=require(_0x1e41('0x1'));var moment=require(_0x1e41('0x2'));var BPromise=require(_0x1e41('0x3'));var rs=require(_0x1e41('0x4'));var fs=require('fs');var Redis=require(_0x1e41('0x5'));var db=require(_0x1e41('0x6'))['db'];var utils=require(_0x1e41('0x7'));var logger=require(_0x1e41('0x8'))('rpc');var config=require(_0x1e41('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x1e41('0xa')][_0x1e41('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x49a291,_0x2ca113,_0x490d65){return new BPromise(function(_0x311d85,_0x215eab){return client[_0x1e41('0xc')](_0x49a291,_0x490d65)[_0x1e41('0xd')](function(_0x13fe21){logger[_0x1e41('0xe')]('Sound,\x20%s,\x20%s',_0x2ca113,'request\x20sent');logger['debug']('Sound,\x20%s,\x20%s,\x20%s',_0x2ca113,_0x1e41('0xf'),JSON[_0x1e41('0x10')](_0x13fe21));if(_0x13fe21[_0x1e41('0x11')]){if(_0x13fe21[_0x1e41('0x11')][_0x1e41('0x12')]===0x1f4){logger[_0x1e41('0x11')](_0x1e41('0x13'),_0x2ca113,_0x13fe21['error'][_0x1e41('0x14')]);return _0x215eab(_0x13fe21[_0x1e41('0x11')][_0x1e41('0x14')]);}logger[_0x1e41('0x11')]('Sound,\x20%s,\x20%s',_0x2ca113,_0x13fe21[_0x1e41('0x11')][_0x1e41('0x14')]);return _0x311d85(_0x13fe21[_0x1e41('0x11')]['message']);}else{logger['info'](_0x1e41('0x13'),_0x2ca113,_0x1e41('0xf'));_0x311d85(_0x13fe21[_0x1e41('0x15')]['message']);}})[_0x1e41('0x16')](function(_0x355c86){logger['error'](_0x1e41('0x13'),_0x2ca113,_0x355c86);_0x215eab(_0x355c86);});});}exports[_0x1e41('0x17')]=function(_0x59a8ff){var _0x11da45=this;return new Promise(function(_0x10fcbc,_0x113f46){return db[_0x1e41('0x18')][_0x1e41('0x19')]({'raw':_0x59a8ff[_0x1e41('0x1a')]?_0x59a8ff[_0x1e41('0x1a')][_0x1e41('0x1b')]===undefined?!![]:![]:!![],'where':_0x59a8ff[_0x1e41('0x1a')]?_0x59a8ff[_0x1e41('0x1a')][_0x1e41('0x1c')]||null:null,'attributes':_0x59a8ff[_0x1e41('0x1a')]?_0x59a8ff[_0x1e41('0x1a')]['attributes']||null:null,'include':_0x59a8ff['options']?_0x59a8ff[_0x1e41('0x1a')]['include']?_[_0x1e41('0x1d')](_0x59a8ff[_0x1e41('0x1a')][_0x1e41('0x1e')],function(_0x281727){return{'model':db[_0x281727[_0x1e41('0x1f')]],'as':_0x281727['as'],'attributes':_0x281727[_0x1e41('0x20')],'include':_0x281727['include']?_[_0x1e41('0x1d')](_0x281727['include'],function(_0xbfc382){return{'model':db[_0xbfc382[_0x1e41('0x1f')]],'as':_0xbfc382['as'],'attributes':_0xbfc382['attributes'],'include':_0xbfc382[_0x1e41('0x1e')]?_[_0x1e41('0x1d')](_0xbfc382[_0x1e41('0x1e')],function(_0x484f51){return{'model':db[_0x484f51[_0x1e41('0x1f')]],'as':_0x484f51['as'],'attributes':_0x484f51[_0x1e41('0x20')]};}):[]};}):[]};}):[]:[]})[_0x1e41('0xd')](function(_0x45137c){logger[_0x1e41('0xe')](_0x1e41('0x17'),_0x59a8ff);logger[_0x1e41('0x21')](_0x1e41('0x17'),_0x59a8ff,JSON[_0x1e41('0x10')](_0x45137c));_0x10fcbc(_0x45137c);})[_0x1e41('0x16')](function(_0x4f8676){logger[_0x1e41('0x11')](_0x1e41('0x17'),_0x4f8676[_0x1e41('0x14')],_0x59a8ff);_0x113f46(_0x11da45['error'](0x1f4,_0x4f8676[_0x1e41('0x14')]));});});};