Built motion from commit b58257bb.|2.5.37
[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 _0xf1d6=['code','Sound,\x20%s,\x20%s','message','info','result','catch','ShowSound','find','options','raw','where','attributes','model','include','map','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','request\x20sent','debug','stringify','error'];(function(_0x3700ce,_0x4c3239){var _0x286b7a=function(_0x27b3eb){while(--_0x27b3eb){_0x3700ce['push'](_0x3700ce['shift']());}};_0x286b7a(++_0x4c3239);}(_0xf1d6,0x12f));var _0x6f1d=function(_0x26cb03,_0x38d271){_0x26cb03=_0x26cb03-0x0;var _0x5b7ac9=_0xf1d6[_0x26cb03];return _0x5b7ac9;};'use strict';var _=require(_0x6f1d('0x0'));var util=require(_0x6f1d('0x1'));var moment=require(_0x6f1d('0x2'));var BPromise=require(_0x6f1d('0x3'));var rs=require(_0x6f1d('0x4'));var fs=require('fs');var Redis=require(_0x6f1d('0x5'));var db=require(_0x6f1d('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x6f1d('0x7'))(_0x6f1d('0x8'));var config=require(_0x6f1d('0x9'));var jayson=require(_0x6f1d('0xa'));var client=jayson['client'][_0x6f1d('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x373046,_0x594033,_0x152d71){return new BPromise(function(_0x1a8b6b,_0x59c91c){return client['request'](_0x373046,_0x152d71)[_0x6f1d('0xc')](function(_0x401d45){logger['info']('Sound,\x20%s,\x20%s',_0x594033,_0x6f1d('0xd'));logger[_0x6f1d('0xe')]('Sound,\x20%s,\x20%s,\x20%s',_0x594033,_0x6f1d('0xd'),JSON[_0x6f1d('0xf')](_0x401d45));if(_0x401d45[_0x6f1d('0x10')]){if(_0x401d45['error'][_0x6f1d('0x11')]===0x1f4){logger['error'](_0x6f1d('0x12'),_0x594033,_0x401d45['error'][_0x6f1d('0x13')]);return _0x59c91c(_0x401d45[_0x6f1d('0x10')][_0x6f1d('0x13')]);}logger['error'](_0x6f1d('0x12'),_0x594033,_0x401d45[_0x6f1d('0x10')]['message']);return _0x1a8b6b(_0x401d45[_0x6f1d('0x10')][_0x6f1d('0x13')]);}else{logger[_0x6f1d('0x14')](_0x6f1d('0x12'),_0x594033,'request\x20sent');_0x1a8b6b(_0x401d45[_0x6f1d('0x15')][_0x6f1d('0x13')]);}})[_0x6f1d('0x16')](function(_0x4374aa){logger['error'](_0x6f1d('0x12'),_0x594033,_0x4374aa);_0x59c91c(_0x4374aa);});});}exports[_0x6f1d('0x17')]=function(_0x5e381d){var _0xcac03c=this;return new Promise(function(_0x5b95ec,_0x2e7876){return db['Sound'][_0x6f1d('0x18')]({'raw':_0x5e381d[_0x6f1d('0x19')]?_0x5e381d[_0x6f1d('0x19')][_0x6f1d('0x1a')]===undefined?!![]:![]:!![],'where':_0x5e381d[_0x6f1d('0x19')]?_0x5e381d[_0x6f1d('0x19')][_0x6f1d('0x1b')]||null:null,'attributes':_0x5e381d['options']?_0x5e381d[_0x6f1d('0x19')][_0x6f1d('0x1c')]||null:null,'include':_0x5e381d['options']?_0x5e381d[_0x6f1d('0x19')]['include']?_['map'](_0x5e381d[_0x6f1d('0x19')]['include'],function(_0x2c174b){return{'model':db[_0x2c174b[_0x6f1d('0x1d')]],'as':_0x2c174b['as'],'attributes':_0x2c174b[_0x6f1d('0x1c')],'include':_0x2c174b[_0x6f1d('0x1e')]?_[_0x6f1d('0x1f')](_0x2c174b['include'],function(_0x348f63){return{'model':db[_0x348f63[_0x6f1d('0x1d')]],'as':_0x348f63['as'],'attributes':_0x348f63[_0x6f1d('0x1c')],'include':_0x348f63[_0x6f1d('0x1e')]?_[_0x6f1d('0x1f')](_0x348f63[_0x6f1d('0x1e')],function(_0x56ff2d){return{'model':db[_0x56ff2d['model']],'as':_0x56ff2d['as'],'attributes':_0x56ff2d[_0x6f1d('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3a38bb){logger[_0x6f1d('0x14')](_0x6f1d('0x17'),_0x5e381d);logger[_0x6f1d('0xe')]('ShowSound',_0x5e381d,JSON[_0x6f1d('0xf')](_0x3a38bb));_0x5b95ec(_0x3a38bb);})[_0x6f1d('0x16')](function(_0x46bc3b){logger[_0x6f1d('0x10')](_0x6f1d('0x17'),_0x46bc3b['message'],_0x5e381d);_0x2e7876(_0xcac03c[_0x6f1d('0x10')](0x1f4,_0x46bc3b[_0x6f1d('0x13')]));});});};