Built motion from commit 1fa89557.|2.6.10
[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 _0x5324=['stringify','error','code','message','result','catch','ShowSound','Sound','find','options','raw','where','include','map','attributes','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','then','info','Sound,\x20%s,\x20%s','debug','Sound,\x20%s,\x20%s,\x20%s'];(function(_0x2f8989,_0x1b7e94){var _0x4dc643=function(_0x22d755){while(--_0x22d755){_0x2f8989['push'](_0x2f8989['shift']());}};_0x4dc643(++_0x1b7e94);}(_0x5324,0xfe));var _0x4532=function(_0x319d6a,_0x478206){_0x319d6a=_0x319d6a-0x0;var _0x36567f=_0x5324[_0x319d6a];return _0x36567f;};'use strict';var _=require(_0x4532('0x0'));var util=require(_0x4532('0x1'));var moment=require(_0x4532('0x2'));var BPromise=require(_0x4532('0x3'));var rs=require(_0x4532('0x4'));var fs=require('fs');var Redis=require(_0x4532('0x5'));var db=require(_0x4532('0x6'))['db'];var utils=require(_0x4532('0x7'));var logger=require(_0x4532('0x8'))(_0x4532('0x9'));var config=require('../../config/environment');var jayson=require(_0x4532('0xa'));var client=jayson[_0x4532('0xb')][_0x4532('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x5af440,_0x581915,_0x167b84){return new BPromise(function(_0x50f47b,_0x31a157){return client['request'](_0x5af440,_0x167b84)[_0x4532('0xd')](function(_0xf53f95){logger[_0x4532('0xe')](_0x4532('0xf'),_0x581915,'request\x20sent');logger[_0x4532('0x10')](_0x4532('0x11'),_0x581915,'request\x20sent',JSON[_0x4532('0x12')](_0xf53f95));if(_0xf53f95[_0x4532('0x13')]){if(_0xf53f95['error'][_0x4532('0x14')]===0x1f4){logger[_0x4532('0x13')](_0x4532('0xf'),_0x581915,_0xf53f95[_0x4532('0x13')][_0x4532('0x15')]);return _0x31a157(_0xf53f95['error'][_0x4532('0x15')]);}logger[_0x4532('0x13')](_0x4532('0xf'),_0x581915,_0xf53f95[_0x4532('0x13')][_0x4532('0x15')]);return _0x50f47b(_0xf53f95[_0x4532('0x13')][_0x4532('0x15')]);}else{logger[_0x4532('0xe')](_0x4532('0xf'),_0x581915,'request\x20sent');_0x50f47b(_0xf53f95[_0x4532('0x16')][_0x4532('0x15')]);}})[_0x4532('0x17')](function(_0x39f74f){logger[_0x4532('0x13')](_0x4532('0xf'),_0x581915,_0x39f74f);_0x31a157(_0x39f74f);});});}exports[_0x4532('0x18')]=function(_0x2e4212){var _0x4f98be=this;return new Promise(function(_0x7e0d51,_0x4e0cb1){return db[_0x4532('0x19')][_0x4532('0x1a')]({'raw':_0x2e4212['options']?_0x2e4212[_0x4532('0x1b')][_0x4532('0x1c')]===undefined?!![]:![]:!![],'where':_0x2e4212[_0x4532('0x1b')]?_0x2e4212[_0x4532('0x1b')][_0x4532('0x1d')]||null:null,'attributes':_0x2e4212['options']?_0x2e4212['options']['attributes']||null:null,'include':_0x2e4212[_0x4532('0x1b')]?_0x2e4212[_0x4532('0x1b')][_0x4532('0x1e')]?_[_0x4532('0x1f')](_0x2e4212[_0x4532('0x1b')][_0x4532('0x1e')],function(_0x3b1464){return{'model':db[_0x3b1464['model']],'as':_0x3b1464['as'],'attributes':_0x3b1464['attributes'],'include':_0x3b1464[_0x4532('0x1e')]?_[_0x4532('0x1f')](_0x3b1464[_0x4532('0x1e')],function(_0x10242f){return{'model':db[_0x10242f['model']],'as':_0x10242f['as'],'attributes':_0x10242f[_0x4532('0x20')],'include':_0x10242f[_0x4532('0x1e')]?_[_0x4532('0x1f')](_0x10242f[_0x4532('0x1e')],function(_0x9bbb88){return{'model':db[_0x9bbb88[_0x4532('0x21')]],'as':_0x9bbb88['as'],'attributes':_0x9bbb88[_0x4532('0x20')]};}):[]};}):[]};}):[]:[]})[_0x4532('0xd')](function(_0x8ad4c2){logger[_0x4532('0xe')]('ShowSound',_0x2e4212);logger['debug'](_0x4532('0x18'),_0x2e4212,JSON['stringify'](_0x8ad4c2));_0x7e0d51(_0x8ad4c2);})['catch'](function(_0x277817){logger['error']('ShowSound',_0x277817[_0x4532('0x15')],_0x2e4212);_0x4e0cb1(_0x4f98be[_0x4532('0x13')](0x1f4,_0x277817[_0x4532('0x15')]));});});};