5ac670820bebff8ec4dd4fa220617f9c0be1d710
[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 _0x0c1f=['rpc','../../config/environment','jayson/promise','client','http','request','then','info','Setting,\x20%s,\x20%s','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','ShowSetting','find','options','raw','where','attributes','include','map','model','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x49282b,_0x4e2125){var _0xcb542e=function(_0x19fb29){while(--_0x19fb29){_0x49282b['push'](_0x49282b['shift']());}};_0xcb542e(++_0x4e2125);}(_0x0c1f,0x1b3));var _0xf0c1=function(_0x2fbedc,_0x25d163){_0x2fbedc=_0x2fbedc-0x0;var _0x56b33e=_0x0c1f[_0x2fbedc];return _0x56b33e;};'use strict';var _=require(_0xf0c1('0x0'));var util=require(_0xf0c1('0x1'));var moment=require(_0xf0c1('0x2'));var BPromise=require(_0xf0c1('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf0c1('0x4'))['db'];var utils=require(_0xf0c1('0x5'));var logger=require(_0xf0c1('0x6'))(_0xf0c1('0x7'));var config=require(_0xf0c1('0x8'));var jayson=require(_0xf0c1('0x9'));var client=jayson[_0xf0c1('0xa')][_0xf0c1('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3a75a6,_0x39fdda,_0xbb13f3){return new BPromise(function(_0x44a05b,_0x4e3485){return client[_0xf0c1('0xc')](_0x3a75a6,_0xbb13f3)[_0xf0c1('0xd')](function(_0x2f60c3){logger[_0xf0c1('0xe')](_0xf0c1('0xf'),_0x39fdda,_0xf0c1('0x10'));logger[_0xf0c1('0x11')](_0xf0c1('0x12'),_0x39fdda,_0xf0c1('0x10'),JSON[_0xf0c1('0x13')](_0x2f60c3));if(_0x2f60c3[_0xf0c1('0x14')]){if(_0x2f60c3[_0xf0c1('0x14')][_0xf0c1('0x15')]===0x1f4){logger[_0xf0c1('0x14')](_0xf0c1('0xf'),_0x39fdda,_0x2f60c3[_0xf0c1('0x14')][_0xf0c1('0x16')]);return _0x4e3485(_0x2f60c3[_0xf0c1('0x14')][_0xf0c1('0x16')]);}logger['error'](_0xf0c1('0xf'),_0x39fdda,_0x2f60c3[_0xf0c1('0x14')][_0xf0c1('0x16')]);return _0x44a05b(_0x2f60c3[_0xf0c1('0x14')][_0xf0c1('0x16')]);}else{logger[_0xf0c1('0xe')]('Setting,\x20%s,\x20%s',_0x39fdda,_0xf0c1('0x10'));_0x44a05b(_0x2f60c3[_0xf0c1('0x17')][_0xf0c1('0x16')]);}})['catch'](function(_0x2964d9){logger[_0xf0c1('0x14')](_0xf0c1('0xf'),_0x39fdda,_0x2964d9);_0x4e3485(_0x2964d9);});});}exports[_0xf0c1('0x18')]=function(_0x292394){var _0x48c4b5=this;return new Promise(function(_0x209bc0,_0x40191d){return db['Setting'][_0xf0c1('0x19')]({'raw':_0x292394[_0xf0c1('0x1a')]?_0x292394[_0xf0c1('0x1a')][_0xf0c1('0x1b')]===undefined?!![]:![]:!![],'where':_0x292394[_0xf0c1('0x1a')]?_0x292394[_0xf0c1('0x1a')][_0xf0c1('0x1c')]||null:null,'attributes':_0x292394['options']?_0x292394[_0xf0c1('0x1a')][_0xf0c1('0x1d')]||null:null,'include':_0x292394[_0xf0c1('0x1a')]?_0x292394['options'][_0xf0c1('0x1e')]?_[_0xf0c1('0x1f')](_0x292394['options'][_0xf0c1('0x1e')],function(_0x21e5ca){return{'model':db[_0x21e5ca['model']],'as':_0x21e5ca['as'],'attributes':_0x21e5ca[_0xf0c1('0x1d')],'include':_0x21e5ca[_0xf0c1('0x1e')]?_[_0xf0c1('0x1f')](_0x21e5ca['include'],function(_0x4d8066){return{'model':db[_0x4d8066[_0xf0c1('0x20')]],'as':_0x4d8066['as'],'attributes':_0x4d8066[_0xf0c1('0x1d')],'include':_0x4d8066['include']?_[_0xf0c1('0x1f')](_0x4d8066[_0xf0c1('0x1e')],function(_0x4ad0ee){return{'model':db[_0x4ad0ee[_0xf0c1('0x20')]],'as':_0x4ad0ee['as'],'attributes':_0x4ad0ee[_0xf0c1('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xf0c1('0xd')](function(_0x4e7ae3){logger[_0xf0c1('0xe')](_0xf0c1('0x18'),_0x292394);logger[_0xf0c1('0x11')](_0xf0c1('0x18'),_0x292394,JSON[_0xf0c1('0x13')](_0x4e7ae3));_0x209bc0(_0x4e7ae3);})[_0xf0c1('0x21')](function(_0x26f9ad){logger[_0xf0c1('0x14')]('ShowSetting',_0x26f9ad[_0xf0c1('0x16')],_0x292394);_0x40191d(_0x48c4b5[_0xf0c1('0x14')](0x1f4,_0x26f9ad[_0xf0c1('0x16')]));});});};