6f5aaaa96e9438beb25875329a5d869a01f9b51e
[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 _0x14f6=['request\x20sent','debug','stringify','error','message','catch','Setting','find','options','raw','where','attributes','map','include','model','ShowSetting','lodash','util','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','info','Setting,\x20%s,\x20%s'];(function(_0x47741d,_0x1849dc){var _0x46d4fe=function(_0x5a5dfe){while(--_0x5a5dfe){_0x47741d['push'](_0x47741d['shift']());}};_0x46d4fe(++_0x1849dc);}(_0x14f6,0x128));var _0x614f=function(_0x5ec8ac,_0x59d133){_0x5ec8ac=_0x5ec8ac-0x0;var _0x2a7f55=_0x14f6[_0x5ec8ac];return _0x2a7f55;};'use strict';var _=require(_0x614f('0x0'));var util=require(_0x614f('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x614f('0x2'));var fs=require('fs');var Redis=require(_0x614f('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x614f('0x4'))(_0x614f('0x5'));var config=require(_0x614f('0x6'));var jayson=require(_0x614f('0x7'));var client=jayson['client'][_0x614f('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x476325,_0x1b0a92,_0x1c3ccf){return new BPromise(function(_0x20d822,_0x547aa6){return client[_0x614f('0x9')](_0x476325,_0x1c3ccf)['then'](function(_0x1bf5c1){logger[_0x614f('0xa')](_0x614f('0xb'),_0x1b0a92,_0x614f('0xc'));logger[_0x614f('0xd')]('Setting,\x20%s,\x20%s,\x20%s',_0x1b0a92,'request\x20sent',JSON[_0x614f('0xe')](_0x1bf5c1));if(_0x1bf5c1[_0x614f('0xf')]){if(_0x1bf5c1['error']['code']===0x1f4){logger[_0x614f('0xf')]('Setting,\x20%s,\x20%s',_0x1b0a92,_0x1bf5c1[_0x614f('0xf')][_0x614f('0x10')]);return _0x547aa6(_0x1bf5c1[_0x614f('0xf')][_0x614f('0x10')]);}logger[_0x614f('0xf')](_0x614f('0xb'),_0x1b0a92,_0x1bf5c1[_0x614f('0xf')]['message']);return _0x20d822(_0x1bf5c1['error'][_0x614f('0x10')]);}else{logger[_0x614f('0xa')]('Setting,\x20%s,\x20%s',_0x1b0a92,_0x614f('0xc'));_0x20d822(_0x1bf5c1['result'][_0x614f('0x10')]);}})[_0x614f('0x11')](function(_0x161cb0){logger[_0x614f('0xf')](_0x614f('0xb'),_0x1b0a92,_0x161cb0);_0x547aa6(_0x161cb0);});});}exports['ShowSetting']=function(_0x358f85){var _0x2f4319=this;return new Promise(function(_0x35ab45,_0x5ba56e){return db[_0x614f('0x12')][_0x614f('0x13')]({'raw':_0x358f85[_0x614f('0x14')]?_0x358f85['options'][_0x614f('0x15')]===undefined?!![]:![]:!![],'where':_0x358f85['options']?_0x358f85[_0x614f('0x14')][_0x614f('0x16')]||null:null,'attributes':_0x358f85[_0x614f('0x14')]?_0x358f85[_0x614f('0x14')][_0x614f('0x17')]||null:null,'include':_0x358f85[_0x614f('0x14')]?_0x358f85[_0x614f('0x14')]['include']?_[_0x614f('0x18')](_0x358f85[_0x614f('0x14')][_0x614f('0x19')],function(_0x1711ea){return{'model':db[_0x1711ea['model']],'as':_0x1711ea['as'],'attributes':_0x1711ea['attributes'],'include':_0x1711ea[_0x614f('0x19')]?_[_0x614f('0x18')](_0x1711ea[_0x614f('0x19')],function(_0x8706a3){return{'model':db[_0x8706a3['model']],'as':_0x8706a3['as'],'attributes':_0x8706a3[_0x614f('0x17')],'include':_0x8706a3[_0x614f('0x19')]?_['map'](_0x8706a3[_0x614f('0x19')],function(_0xe0874){return{'model':db[_0xe0874[_0x614f('0x1a')]],'as':_0xe0874['as'],'attributes':_0xe0874[_0x614f('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5e5a4b){logger['info']('ShowSetting',_0x358f85);logger[_0x614f('0xd')](_0x614f('0x1b'),_0x358f85,JSON['stringify'](_0x5e5a4b));_0x35ab45(_0x5e5a4b);})['catch'](function(_0x10e767){logger['error'](_0x614f('0x1b'),_0x10e767[_0x614f('0x10')],_0x358f85);_0x5ba56e(_0x2f4319[_0x614f('0xf')](0x1f4,_0x10e767[_0x614f('0x10')]));});});};