4602afb0a8a8c33093a17d4bc913775567071b8c
[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 _0x9580=['find','options','raw','where','attributes','include','map','model','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','request\x20sent','debug','Sound,\x20%s,\x20%s,\x20%s','stringify','error','Sound,\x20%s,\x20%s','message','result','catch','ShowSound','Sound'];(function(_0x30d4e1,_0x3ecc06){var _0x318e7c=function(_0x1fd47c){while(--_0x1fd47c){_0x30d4e1['push'](_0x30d4e1['shift']());}};_0x318e7c(++_0x3ecc06);}(_0x9580,0x88));var _0x0958=function(_0xd4fef5,_0x290ebc){_0xd4fef5=_0xd4fef5-0x0;var _0x479118=_0x9580[_0xd4fef5];return _0x479118;};'use strict';var _=require('lodash');var util=require(_0x0958('0x0'));var moment=require(_0x0958('0x1'));var BPromise=require(_0x0958('0x2'));var rs=require(_0x0958('0x3'));var fs=require('fs');var Redis=require(_0x0958('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x0958('0x5'));var logger=require(_0x0958('0x6'))(_0x0958('0x7'));var config=require(_0x0958('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x0958('0x9')][_0x0958('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x55fbcf,_0x5afde9,_0x158918){return new BPromise(function(_0xcd0a8e,_0x39010c){return client[_0x0958('0xb')](_0x55fbcf,_0x158918)[_0x0958('0xc')](function(_0x5e3a64){logger['info']('Sound,\x20%s,\x20%s',_0x5afde9,_0x0958('0xd'));logger[_0x0958('0xe')](_0x0958('0xf'),_0x5afde9,_0x0958('0xd'),JSON[_0x0958('0x10')](_0x5e3a64));if(_0x5e3a64[_0x0958('0x11')]){if(_0x5e3a64[_0x0958('0x11')]['code']===0x1f4){logger[_0x0958('0x11')](_0x0958('0x12'),_0x5afde9,_0x5e3a64[_0x0958('0x11')][_0x0958('0x13')]);return _0x39010c(_0x5e3a64['error'][_0x0958('0x13')]);}logger[_0x0958('0x11')](_0x0958('0x12'),_0x5afde9,_0x5e3a64[_0x0958('0x11')][_0x0958('0x13')]);return _0xcd0a8e(_0x5e3a64['error'][_0x0958('0x13')]);}else{logger['info']('Sound,\x20%s,\x20%s',_0x5afde9,_0x0958('0xd'));_0xcd0a8e(_0x5e3a64[_0x0958('0x14')][_0x0958('0x13')]);}})[_0x0958('0x15')](function(_0x1d9db4){logger[_0x0958('0x11')](_0x0958('0x12'),_0x5afde9,_0x1d9db4);_0x39010c(_0x1d9db4);});});}exports[_0x0958('0x16')]=function(_0x56d8fd){var _0x4c609c=this;return new Promise(function(_0x56dabb,_0x24b988){return db[_0x0958('0x17')][_0x0958('0x18')]({'raw':_0x56d8fd[_0x0958('0x19')]?_0x56d8fd[_0x0958('0x19')][_0x0958('0x1a')]===undefined?!![]:![]:!![],'where':_0x56d8fd[_0x0958('0x19')]?_0x56d8fd[_0x0958('0x19')][_0x0958('0x1b')]||null:null,'attributes':_0x56d8fd[_0x0958('0x19')]?_0x56d8fd['options'][_0x0958('0x1c')]||null:null,'include':_0x56d8fd[_0x0958('0x19')]?_0x56d8fd['options'][_0x0958('0x1d')]?_[_0x0958('0x1e')](_0x56d8fd['options'][_0x0958('0x1d')],function(_0x8b8167){return{'model':db[_0x8b8167[_0x0958('0x1f')]],'as':_0x8b8167['as'],'attributes':_0x8b8167['attributes'],'include':_0x8b8167[_0x0958('0x1d')]?_[_0x0958('0x1e')](_0x8b8167[_0x0958('0x1d')],function(_0x232f06){return{'model':db[_0x232f06[_0x0958('0x1f')]],'as':_0x232f06['as'],'attributes':_0x232f06[_0x0958('0x1c')],'include':_0x232f06['include']?_[_0x0958('0x1e')](_0x232f06['include'],function(_0x553fa1){return{'model':db[_0x553fa1[_0x0958('0x1f')]],'as':_0x553fa1['as'],'attributes':_0x553fa1[_0x0958('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3f17bf){logger['info'](_0x0958('0x16'),_0x56d8fd);logger[_0x0958('0xe')](_0x0958('0x16'),_0x56d8fd,JSON[_0x0958('0x10')](_0x3f17bf));_0x56dabb(_0x3f17bf);})[_0x0958('0x15')](function(_0x4a58e7){logger[_0x0958('0x11')](_0x0958('0x16'),_0x4a58e7[_0x0958('0x13')],_0x56d8fd);_0x24b988(_0x4c609c['error'](0x1f4,_0x4a58e7['message']));});});};