a264593052dd8df17727f5224d343ea84f83d69f
[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 _0x4c64=['map','model','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','info','Setting,\x20%s,\x20%s','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSetting','Setting','find','options','where','attributes','include'];(function(_0x25ab2c,_0x4d586e){var _0xba0d34=function(_0x29b3ef){while(--_0x29b3ef){_0x25ab2c['push'](_0x25ab2c['shift']());}};_0xba0d34(++_0x4d586e);}(_0x4c64,0x142));var _0x44c6=function(_0xa8d7ef,_0x4b8b3d){_0xa8d7ef=_0xa8d7ef-0x0;var _0x239d5e=_0x4c64[_0xa8d7ef];return _0x239d5e;};'use strict';var _=require(_0x44c6('0x0'));var util=require('util');var moment=require(_0x44c6('0x1'));var BPromise=require(_0x44c6('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x44c6('0x3'));var db=require(_0x44c6('0x4'))['db'];var utils=require(_0x44c6('0x5'));var logger=require(_0x44c6('0x6'))('rpc');var config=require(_0x44c6('0x7'));var jayson=require(_0x44c6('0x8'));var client=jayson[_0x44c6('0x9')][_0x44c6('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3f1090,_0x367701,_0x5530f8){return new BPromise(function(_0x17a6b1,_0x3f5498){return client['request'](_0x3f1090,_0x5530f8)[_0x44c6('0xb')](function(_0x47c637){logger[_0x44c6('0xc')](_0x44c6('0xd'),_0x367701,_0x44c6('0xe'));logger[_0x44c6('0xf')](_0x44c6('0x10'),_0x367701,_0x44c6('0xe'),JSON[_0x44c6('0x11')](_0x47c637));if(_0x47c637[_0x44c6('0x12')]){if(_0x47c637[_0x44c6('0x12')][_0x44c6('0x13')]===0x1f4){logger['error'](_0x44c6('0xd'),_0x367701,_0x47c637[_0x44c6('0x12')][_0x44c6('0x14')]);return _0x3f5498(_0x47c637[_0x44c6('0x12')]['message']);}logger[_0x44c6('0x12')](_0x44c6('0xd'),_0x367701,_0x47c637['error']['message']);return _0x17a6b1(_0x47c637[_0x44c6('0x12')][_0x44c6('0x14')]);}else{logger[_0x44c6('0xc')](_0x44c6('0xd'),_0x367701,'request\x20sent');_0x17a6b1(_0x47c637[_0x44c6('0x15')]['message']);}})[_0x44c6('0x16')](function(_0x528af4){logger[_0x44c6('0x12')]('Setting,\x20%s,\x20%s',_0x367701,_0x528af4);_0x3f5498(_0x528af4);});});}exports[_0x44c6('0x17')]=function(_0x3b0087){var _0x1308a2=this;return new Promise(function(_0x5ce3be,_0x1d3d00){return db[_0x44c6('0x18')][_0x44c6('0x19')]({'raw':_0x3b0087[_0x44c6('0x1a')]?_0x3b0087['options']['raw']===undefined?!![]:![]:!![],'where':_0x3b0087[_0x44c6('0x1a')]?_0x3b0087[_0x44c6('0x1a')][_0x44c6('0x1b')]||null:null,'attributes':_0x3b0087['options']?_0x3b0087[_0x44c6('0x1a')][_0x44c6('0x1c')]||null:null,'include':_0x3b0087[_0x44c6('0x1a')]?_0x3b0087[_0x44c6('0x1a')][_0x44c6('0x1d')]?_[_0x44c6('0x1e')](_0x3b0087['options']['include'],function(_0x1786ed){return{'model':db[_0x1786ed[_0x44c6('0x1f')]],'as':_0x1786ed['as'],'attributes':_0x1786ed[_0x44c6('0x1c')],'include':_0x1786ed[_0x44c6('0x1d')]?_['map'](_0x1786ed[_0x44c6('0x1d')],function(_0x55fed4){return{'model':db[_0x55fed4['model']],'as':_0x55fed4['as'],'attributes':_0x55fed4[_0x44c6('0x1c')],'include':_0x55fed4[_0x44c6('0x1d')]?_[_0x44c6('0x1e')](_0x55fed4[_0x44c6('0x1d')],function(_0x5c4bc8){return{'model':db[_0x5c4bc8[_0x44c6('0x1f')]],'as':_0x5c4bc8['as'],'attributes':_0x5c4bc8[_0x44c6('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x44c6('0xb')](function(_0x5378b0){logger[_0x44c6('0xc')](_0x44c6('0x17'),_0x3b0087);logger['debug'](_0x44c6('0x17'),_0x3b0087,JSON['stringify'](_0x5378b0));_0x5ce3be(_0x5378b0);})[_0x44c6('0x16')](function(_0x999a70){logger[_0x44c6('0x12')](_0x44c6('0x17'),_0x999a70[_0x44c6('0x14')],_0x3b0087);_0x1d3d00(_0x1308a2['error'](0x1f4,_0x999a70[_0x44c6('0x14')]));});});};