Built motion from commit 0c5f406c.|2.6.29
[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 _0xd471=['raw','where','attributes','include','map','model','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','code','Sound,\x20%s,\x20%s','message','info','catch','ShowSound','Sound','find','options'];(function(_0x71b765,_0x3053f8){var _0x34cb24=function(_0x2dd237){while(--_0x2dd237){_0x71b765['push'](_0x71b765['shift']());}};_0x34cb24(++_0x3053f8);}(_0xd471,0x6c));var _0x1d47=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0xd471[_0xa464c9];return _0x3d73c4;};'use strict';var _=require(_0x1d47('0x0'));var util=require('util');var moment=require(_0x1d47('0x1'));var BPromise=require(_0x1d47('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1d47('0x3'));var db=require(_0x1d47('0x4'))['db'];var utils=require(_0x1d47('0x5'));var logger=require(_0x1d47('0x6'))(_0x1d47('0x7'));var config=require(_0x1d47('0x8'));var jayson=require(_0x1d47('0x9'));var client=jayson[_0x1d47('0xa')][_0x1d47('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x17376a,_0x163e4,_0x39b863){return new BPromise(function(_0x43f0b8,_0x3bb6ec){return client[_0x1d47('0xc')](_0x17376a,_0x39b863)[_0x1d47('0xd')](function(_0x334a29){logger['info']('Sound,\x20%s,\x20%s',_0x163e4,_0x1d47('0xe'));logger[_0x1d47('0xf')](_0x1d47('0x10'),_0x163e4,_0x1d47('0xe'),JSON[_0x1d47('0x11')](_0x334a29));if(_0x334a29[_0x1d47('0x12')]){if(_0x334a29[_0x1d47('0x12')][_0x1d47('0x13')]===0x1f4){logger['error'](_0x1d47('0x14'),_0x163e4,_0x334a29[_0x1d47('0x12')][_0x1d47('0x15')]);return _0x3bb6ec(_0x334a29[_0x1d47('0x12')]['message']);}logger['error'](_0x1d47('0x14'),_0x163e4,_0x334a29[_0x1d47('0x12')][_0x1d47('0x15')]);return _0x43f0b8(_0x334a29[_0x1d47('0x12')][_0x1d47('0x15')]);}else{logger[_0x1d47('0x16')](_0x1d47('0x14'),_0x163e4,_0x1d47('0xe'));_0x43f0b8(_0x334a29['result'][_0x1d47('0x15')]);}})[_0x1d47('0x17')](function(_0x3bff33){logger[_0x1d47('0x12')](_0x1d47('0x14'),_0x163e4,_0x3bff33);_0x3bb6ec(_0x3bff33);});});}exports[_0x1d47('0x18')]=function(_0xe47edf){var _0x3d8250=this;return new Promise(function(_0x39bcb1,_0x49c71d){return db[_0x1d47('0x19')][_0x1d47('0x1a')]({'raw':_0xe47edf[_0x1d47('0x1b')]?_0xe47edf[_0x1d47('0x1b')][_0x1d47('0x1c')]===undefined?!![]:![]:!![],'where':_0xe47edf[_0x1d47('0x1b')]?_0xe47edf[_0x1d47('0x1b')][_0x1d47('0x1d')]||null:null,'attributes':_0xe47edf[_0x1d47('0x1b')]?_0xe47edf['options'][_0x1d47('0x1e')]||null:null,'include':_0xe47edf[_0x1d47('0x1b')]?_0xe47edf['options'][_0x1d47('0x1f')]?_[_0x1d47('0x20')](_0xe47edf[_0x1d47('0x1b')][_0x1d47('0x1f')],function(_0x571b69){return{'model':db[_0x571b69[_0x1d47('0x21')]],'as':_0x571b69['as'],'attributes':_0x571b69[_0x1d47('0x1e')],'include':_0x571b69[_0x1d47('0x1f')]?_['map'](_0x571b69[_0x1d47('0x1f')],function(_0x225152){return{'model':db[_0x225152[_0x1d47('0x21')]],'as':_0x225152['as'],'attributes':_0x225152[_0x1d47('0x1e')],'include':_0x225152['include']?_[_0x1d47('0x20')](_0x225152['include'],function(_0x34ba45){return{'model':db[_0x34ba45['model']],'as':_0x34ba45['as'],'attributes':_0x34ba45[_0x1d47('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x1d47('0xd')](function(_0x5261fc){logger[_0x1d47('0x16')](_0x1d47('0x18'),_0xe47edf);logger[_0x1d47('0xf')](_0x1d47('0x18'),_0xe47edf,JSON[_0x1d47('0x11')](_0x5261fc));_0x39bcb1(_0x5261fc);})[_0x1d47('0x17')](function(_0x5997ff){logger['error'](_0x1d47('0x18'),_0x5997ff[_0x1d47('0x15')],_0xe47edf);_0x49c71d(_0x3d8250[_0x1d47('0x12')](0x1f4,_0x5997ff[_0x1d47('0x15')]));});});};