Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / setting / setting.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 _0x4121=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','request\x20sent','error','Setting,\x20%s,\x20%s','message','result','catch','Setting','find','options','raw','attributes','include','map','model','ShowSetting','debug','stringify','lodash','util'];(function(_0x36bf4a,_0x13cf2f){var _0x3588c6=function(_0x459d5c){while(--_0x459d5c){_0x36bf4a['push'](_0x36bf4a['shift']());}};_0x3588c6(++_0x13cf2f);}(_0x4121,0x1ee));var _0x1412=function(_0x56b969,_0x40b750){_0x56b969=_0x56b969-0x0;var _0x1b87f8=_0x4121[_0x56b969];return _0x1b87f8;};'use strict';var _=require(_0x1412('0x0'));var util=require(_0x1412('0x1'));var moment=require('moment');var BPromise=require(_0x1412('0x2'));var rs=require(_0x1412('0x3'));var fs=require('fs');var Redis=require(_0x1412('0x4'));var db=require(_0x1412('0x5'))['db'];var utils=require(_0x1412('0x6'));var logger=require(_0x1412('0x7'))(_0x1412('0x8'));var config=require(_0x1412('0x9'));var jayson=require(_0x1412('0xa'));var client=jayson['client'][_0x1412('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x461f14,_0x41bf63,_0x477fb5){return new BPromise(function(_0x5e0018,_0x216189){return client['request'](_0x461f14,_0x477fb5)[_0x1412('0xc')](function(_0x4d2ae7){logger[_0x1412('0xd')]('Setting,\x20%s,\x20%s',_0x41bf63,_0x1412('0xe'));logger['debug']('Setting,\x20%s,\x20%s,\x20%s',_0x41bf63,'request\x20sent',JSON['stringify'](_0x4d2ae7));if(_0x4d2ae7[_0x1412('0xf')]){if(_0x4d2ae7[_0x1412('0xf')]['code']===0x1f4){logger['error'](_0x1412('0x10'),_0x41bf63,_0x4d2ae7[_0x1412('0xf')][_0x1412('0x11')]);return _0x216189(_0x4d2ae7[_0x1412('0xf')][_0x1412('0x11')]);}logger[_0x1412('0xf')]('Setting,\x20%s,\x20%s',_0x41bf63,_0x4d2ae7['error'][_0x1412('0x11')]);return _0x5e0018(_0x4d2ae7[_0x1412('0xf')][_0x1412('0x11')]);}else{logger[_0x1412('0xd')](_0x1412('0x10'),_0x41bf63,_0x1412('0xe'));_0x5e0018(_0x4d2ae7[_0x1412('0x12')][_0x1412('0x11')]);}})[_0x1412('0x13')](function(_0x4a213b){logger[_0x1412('0xf')](_0x1412('0x10'),_0x41bf63,_0x4a213b);_0x216189(_0x4a213b);});});}exports['ShowSetting']=function(_0xc86a18){var _0x147b98=this;return new Promise(function(_0x28c92f,_0x2fd6b8){return db[_0x1412('0x14')][_0x1412('0x15')]({'raw':_0xc86a18[_0x1412('0x16')]?_0xc86a18[_0x1412('0x16')][_0x1412('0x17')]===undefined?!![]:![]:!![],'where':_0xc86a18[_0x1412('0x16')]?_0xc86a18[_0x1412('0x16')]['where']||null:null,'attributes':_0xc86a18[_0x1412('0x16')]?_0xc86a18['options'][_0x1412('0x18')]||null:null,'include':_0xc86a18[_0x1412('0x16')]?_0xc86a18[_0x1412('0x16')][_0x1412('0x19')]?_[_0x1412('0x1a')](_0xc86a18['options'][_0x1412('0x19')],function(_0x2e718e){return{'model':db[_0x2e718e[_0x1412('0x1b')]],'as':_0x2e718e['as'],'attributes':_0x2e718e['attributes'],'include':_0x2e718e['include']?_[_0x1412('0x1a')](_0x2e718e['include'],function(_0x32b11d){return{'model':db[_0x32b11d[_0x1412('0x1b')]],'as':_0x32b11d['as'],'attributes':_0x32b11d[_0x1412('0x18')],'include':_0x32b11d[_0x1412('0x19')]?_[_0x1412('0x1a')](_0x32b11d[_0x1412('0x19')],function(_0x23c6c2){return{'model':db[_0x23c6c2[_0x1412('0x1b')]],'as':_0x23c6c2['as'],'attributes':_0x23c6c2[_0x1412('0x18')]};}):[]};}):[]};}):[]:[]})[_0x1412('0xc')](function(_0x313239){logger['info'](_0x1412('0x1c'),_0xc86a18);logger[_0x1412('0x1d')](_0x1412('0x1c'),_0xc86a18,JSON[_0x1412('0x1e')](_0x313239));_0x28c92f(_0x313239);})['catch'](function(_0x12ac8a){logger[_0x1412('0xf')](_0x1412('0x1c'),_0x12ac8a['message'],_0xc86a18);_0x2fd6b8(_0x147b98[_0x1412('0xf')](0x1f4,_0x12ac8a[_0x1412('0x11')]));});});};