Built motion from commit fe909640.|2.6.8
[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 _0x53a0=['message','result','catch','ShowSetting','Setting','find','options','raw','attributes','map','include','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','Setting,\x20%s,\x20%s','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x483c27,_0x48a4d5){var _0x493878=function(_0x133b82){while(--_0x133b82){_0x483c27['push'](_0x483c27['shift']());}};_0x493878(++_0x48a4d5);}(_0x53a0,0x160));var _0x053a=function(_0x21a9d9,_0x4d5ac8){_0x21a9d9=_0x21a9d9-0x0;var _0x46adce=_0x53a0[_0x21a9d9];return _0x46adce;};'use strict';var _=require(_0x053a('0x0'));var util=require(_0x053a('0x1'));var moment=require(_0x053a('0x2'));var BPromise=require(_0x053a('0x3'));var rs=require(_0x053a('0x4'));var fs=require('fs');var Redis=require(_0x053a('0x5'));var db=require(_0x053a('0x6'))['db'];var utils=require(_0x053a('0x7'));var logger=require(_0x053a('0x8'))(_0x053a('0x9'));var config=require(_0x053a('0xa'));var jayson=require(_0x053a('0xb'));var client=jayson[_0x053a('0xc')][_0x053a('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x44d749,_0x4f0e81,_0x582eba){return new BPromise(function(_0x1747c2,_0x404f91){return client['request'](_0x44d749,_0x582eba)[_0x053a('0xe')](function(_0x12d680){logger['info'](_0x053a('0xf'),_0x4f0e81,_0x053a('0x10'));logger[_0x053a('0x11')](_0x053a('0x12'),_0x4f0e81,_0x053a('0x10'),JSON[_0x053a('0x13')](_0x12d680));if(_0x12d680[_0x053a('0x14')]){if(_0x12d680[_0x053a('0x14')][_0x053a('0x15')]===0x1f4){logger[_0x053a('0x14')]('Setting,\x20%s,\x20%s',_0x4f0e81,_0x12d680[_0x053a('0x14')][_0x053a('0x16')]);return _0x404f91(_0x12d680[_0x053a('0x14')][_0x053a('0x16')]);}logger[_0x053a('0x14')](_0x053a('0xf'),_0x4f0e81,_0x12d680[_0x053a('0x14')][_0x053a('0x16')]);return _0x1747c2(_0x12d680['error']['message']);}else{logger['info'](_0x053a('0xf'),_0x4f0e81,'request\x20sent');_0x1747c2(_0x12d680[_0x053a('0x17')][_0x053a('0x16')]);}})[_0x053a('0x18')](function(_0x3f3e1c){logger[_0x053a('0x14')](_0x053a('0xf'),_0x4f0e81,_0x3f3e1c);_0x404f91(_0x3f3e1c);});});}exports[_0x053a('0x19')]=function(_0x11fa19){var _0x35f92d=this;return new Promise(function(_0x4d35ce,_0x81fac1){return db[_0x053a('0x1a')][_0x053a('0x1b')]({'raw':_0x11fa19['options']?_0x11fa19[_0x053a('0x1c')][_0x053a('0x1d')]===undefined?!![]:![]:!![],'where':_0x11fa19[_0x053a('0x1c')]?_0x11fa19[_0x053a('0x1c')]['where']||null:null,'attributes':_0x11fa19['options']?_0x11fa19[_0x053a('0x1c')][_0x053a('0x1e')]||null:null,'include':_0x11fa19[_0x053a('0x1c')]?_0x11fa19[_0x053a('0x1c')]['include']?_[_0x053a('0x1f')](_0x11fa19[_0x053a('0x1c')]['include'],function(_0x4f636d){return{'model':db[_0x4f636d['model']],'as':_0x4f636d['as'],'attributes':_0x4f636d['attributes'],'include':_0x4f636d[_0x053a('0x20')]?_['map'](_0x4f636d[_0x053a('0x20')],function(_0xa07f18){return{'model':db[_0xa07f18[_0x053a('0x21')]],'as':_0xa07f18['as'],'attributes':_0xa07f18['attributes'],'include':_0xa07f18[_0x053a('0x20')]?_[_0x053a('0x1f')](_0xa07f18[_0x053a('0x20')],function(_0xa08f2){return{'model':db[_0xa08f2[_0x053a('0x21')]],'as':_0xa08f2['as'],'attributes':_0xa08f2[_0x053a('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x053a('0xe')](function(_0x2b8f3f){logger['info']('ShowSetting',_0x11fa19);logger[_0x053a('0x11')](_0x053a('0x19'),_0x11fa19,JSON['stringify'](_0x2b8f3f));_0x4d35ce(_0x2b8f3f);})[_0x053a('0x18')](function(_0x39d6bc){logger['error'](_0x053a('0x19'),_0x39d6bc[_0x053a('0x16')],_0x11fa19);_0x81fac1(_0x35f92d[_0x053a('0x14')](0x1f4,_0x39d6bc[_0x053a('0x16')]));});});};