Built motion from commit 85328c08.|2.5.50
[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 _0x9413=['Setting,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','catch','ShowSetting','Setting','find','options','raw','where','attributes','include','map','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','info'];(function(_0x35f9c4,_0x511cbd){var _0x40e2ea=function(_0x4e1ab4){while(--_0x4e1ab4){_0x35f9c4['push'](_0x35f9c4['shift']());}};_0x40e2ea(++_0x511cbd);}(_0x9413,0x15c));var _0x3941=function(_0x673722,_0x275d7e){_0x673722=_0x673722-0x0;var _0x21249c=_0x9413[_0x673722];return _0x21249c;};'use strict';var _=require(_0x3941('0x0'));var util=require(_0x3941('0x1'));var moment=require(_0x3941('0x2'));var BPromise=require(_0x3941('0x3'));var rs=require(_0x3941('0x4'));var fs=require('fs');var Redis=require(_0x3941('0x5'));var db=require(_0x3941('0x6'))['db'];var utils=require(_0x3941('0x7'));var logger=require('../../config/logger')(_0x3941('0x8'));var config=require(_0x3941('0x9'));var jayson=require(_0x3941('0xa'));var client=jayson[_0x3941('0xb')][_0x3941('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x6cbef4,_0x540ce1,_0x504508){return new BPromise(function(_0x1ebd19,_0x529080){return client[_0x3941('0xd')](_0x6cbef4,_0x504508)['then'](function(_0x4b674d){logger[_0x3941('0xe')](_0x3941('0xf'),_0x540ce1,'request\x20sent');logger[_0x3941('0x10')]('Setting,\x20%s,\x20%s,\x20%s',_0x540ce1,_0x3941('0x11'),JSON[_0x3941('0x12')](_0x4b674d));if(_0x4b674d['error']){if(_0x4b674d[_0x3941('0x13')][_0x3941('0x14')]===0x1f4){logger[_0x3941('0x13')](_0x3941('0xf'),_0x540ce1,_0x4b674d['error'][_0x3941('0x15')]);return _0x529080(_0x4b674d[_0x3941('0x13')][_0x3941('0x15')]);}logger[_0x3941('0x13')](_0x3941('0xf'),_0x540ce1,_0x4b674d[_0x3941('0x13')][_0x3941('0x15')]);return _0x1ebd19(_0x4b674d['error']['message']);}else{logger[_0x3941('0xe')]('Setting,\x20%s,\x20%s',_0x540ce1,_0x3941('0x11'));_0x1ebd19(_0x4b674d['result'][_0x3941('0x15')]);}})[_0x3941('0x16')](function(_0x17e261){logger['error'](_0x3941('0xf'),_0x540ce1,_0x17e261);_0x529080(_0x17e261);});});}exports[_0x3941('0x17')]=function(_0x68e75e){var _0x9bdbab=this;return new Promise(function(_0x102de0,_0x3239a0){return db[_0x3941('0x18')][_0x3941('0x19')]({'raw':_0x68e75e[_0x3941('0x1a')]?_0x68e75e[_0x3941('0x1a')][_0x3941('0x1b')]===undefined?!![]:![]:!![],'where':_0x68e75e[_0x3941('0x1a')]?_0x68e75e['options'][_0x3941('0x1c')]||null:null,'attributes':_0x68e75e[_0x3941('0x1a')]?_0x68e75e[_0x3941('0x1a')][_0x3941('0x1d')]||null:null,'include':_0x68e75e[_0x3941('0x1a')]?_0x68e75e[_0x3941('0x1a')][_0x3941('0x1e')]?_[_0x3941('0x1f')](_0x68e75e[_0x3941('0x1a')]['include'],function(_0x431039){return{'model':db[_0x431039[_0x3941('0x20')]],'as':_0x431039['as'],'attributes':_0x431039['attributes'],'include':_0x431039[_0x3941('0x1e')]?_[_0x3941('0x1f')](_0x431039['include'],function(_0x5b643c){return{'model':db[_0x5b643c[_0x3941('0x20')]],'as':_0x5b643c['as'],'attributes':_0x5b643c[_0x3941('0x1d')],'include':_0x5b643c[_0x3941('0x1e')]?_[_0x3941('0x1f')](_0x5b643c[_0x3941('0x1e')],function(_0x894d4c){return{'model':db[_0x894d4c[_0x3941('0x20')]],'as':_0x894d4c['as'],'attributes':_0x894d4c['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x46b44){logger[_0x3941('0xe')](_0x3941('0x17'),_0x68e75e);logger['debug']('ShowSetting',_0x68e75e,JSON['stringify'](_0x46b44));_0x102de0(_0x46b44);})['catch'](function(_0x16fe71){logger[_0x3941('0x13')](_0x3941('0x17'),_0x16fe71[_0x3941('0x15')],_0x68e75e);_0x3239a0(_0x9bdbab[_0x3941('0x13')](0x1f4,_0x16fe71[_0x3941('0x15')]));});});};