Built motion from commit 19a84241.|2.5.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 _0x3f3b=['include','model','map','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message','Setting,\x20%s,\x20%s','result','catch','ShowSetting','Setting','options','raw','where','attributes'];(function(_0x350a0a,_0x54ce79){var _0x25702b=function(_0x50d1a5){while(--_0x50d1a5){_0x350a0a['push'](_0x350a0a['shift']());}};_0x25702b(++_0x54ce79);}(_0x3f3b,0x135));var _0xb3f3=function(_0xc8fcb2,_0x25c8e8){_0xc8fcb2=_0xc8fcb2-0x0;var _0x195c21=_0x3f3b[_0xc8fcb2];return _0x195c21;};'use strict';var _=require('lodash');var util=require(_0xb3f3('0x0'));var moment=require(_0xb3f3('0x1'));var BPromise=require(_0xb3f3('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb3f3('0x3'));var db=require(_0xb3f3('0x4'))['db'];var utils=require(_0xb3f3('0x5'));var logger=require(_0xb3f3('0x6'))(_0xb3f3('0x7'));var config=require(_0xb3f3('0x8'));var jayson=require(_0xb3f3('0x9'));var client=jayson[_0xb3f3('0xa')][_0xb3f3('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x31aa70,_0x477e4c,_0x20f578){return new BPromise(function(_0x7be145,_0x343e76){return client[_0xb3f3('0xc')](_0x31aa70,_0x20f578)[_0xb3f3('0xd')](function(_0x41f16d){logger[_0xb3f3('0xe')]('Setting,\x20%s,\x20%s',_0x477e4c,_0xb3f3('0xf'));logger[_0xb3f3('0x10')](_0xb3f3('0x11'),_0x477e4c,_0xb3f3('0xf'),JSON[_0xb3f3('0x12')](_0x41f16d));if(_0x41f16d[_0xb3f3('0x13')]){if(_0x41f16d[_0xb3f3('0x13')][_0xb3f3('0x14')]===0x1f4){logger[_0xb3f3('0x13')]('Setting,\x20%s,\x20%s',_0x477e4c,_0x41f16d[_0xb3f3('0x13')][_0xb3f3('0x15')]);return _0x343e76(_0x41f16d[_0xb3f3('0x13')][_0xb3f3('0x15')]);}logger[_0xb3f3('0x13')]('Setting,\x20%s,\x20%s',_0x477e4c,_0x41f16d[_0xb3f3('0x13')][_0xb3f3('0x15')]);return _0x7be145(_0x41f16d[_0xb3f3('0x13')][_0xb3f3('0x15')]);}else{logger[_0xb3f3('0xe')](_0xb3f3('0x16'),_0x477e4c,_0xb3f3('0xf'));_0x7be145(_0x41f16d[_0xb3f3('0x17')][_0xb3f3('0x15')]);}})[_0xb3f3('0x18')](function(_0x12bad2){logger[_0xb3f3('0x13')]('Setting,\x20%s,\x20%s',_0x477e4c,_0x12bad2);_0x343e76(_0x12bad2);});});}exports[_0xb3f3('0x19')]=function(_0x232c91){var _0x17f693=this;return new Promise(function(_0x229d53,_0x45c7c1){return db[_0xb3f3('0x1a')]['find']({'raw':_0x232c91['options']?_0x232c91[_0xb3f3('0x1b')][_0xb3f3('0x1c')]===undefined?!![]:![]:!![],'where':_0x232c91[_0xb3f3('0x1b')]?_0x232c91['options'][_0xb3f3('0x1d')]||null:null,'attributes':_0x232c91['options']?_0x232c91['options'][_0xb3f3('0x1e')]||null:null,'include':_0x232c91[_0xb3f3('0x1b')]?_0x232c91[_0xb3f3('0x1b')][_0xb3f3('0x1f')]?_['map'](_0x232c91[_0xb3f3('0x1b')]['include'],function(_0x1bae77){return{'model':db[_0x1bae77[_0xb3f3('0x20')]],'as':_0x1bae77['as'],'attributes':_0x1bae77[_0xb3f3('0x1e')],'include':_0x1bae77[_0xb3f3('0x1f')]?_[_0xb3f3('0x21')](_0x1bae77['include'],function(_0x2cfaa2){return{'model':db[_0x2cfaa2['model']],'as':_0x2cfaa2['as'],'attributes':_0x2cfaa2['attributes'],'include':_0x2cfaa2['include']?_['map'](_0x2cfaa2['include'],function(_0x2bf308){return{'model':db[_0x2bf308[_0xb3f3('0x20')]],'as':_0x2bf308['as'],'attributes':_0x2bf308[_0xb3f3('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb3f3('0xd')](function(_0x4fa147){logger['info'](_0xb3f3('0x19'),_0x232c91);logger[_0xb3f3('0x10')](_0xb3f3('0x19'),_0x232c91,JSON[_0xb3f3('0x12')](_0x4fa147));_0x229d53(_0x4fa147);})[_0xb3f3('0x18')](function(_0xece999){logger[_0xb3f3('0x13')](_0xb3f3('0x19'),_0xece999[_0xb3f3('0x15')],_0x232c91);_0x45c7c1(_0x17f693[_0xb3f3('0x13')](0x1f4,_0xece999[_0xb3f3('0x15')]));});});};