Built motion from commit b5413ace.|2.6.9
[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 _0x1513=['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','catch','ShowSetting','find','options','raw','attributes','map','include','model','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x305b7b,_0x157492){var _0x3a3ee3=function(_0x4115ea){while(--_0x4115ea){_0x305b7b['push'](_0x305b7b['shift']());}};_0x3a3ee3(++_0x157492);}(_0x1513,0x19a));var _0x3151=function(_0xf655aa,_0x4837fa){_0xf655aa=_0xf655aa-0x0;var _0x4bc997=_0x1513[_0xf655aa];return _0x4bc997;};'use strict';var _=require(_0x3151('0x0'));var util=require('util');var moment=require(_0x3151('0x1'));var BPromise=require('bluebird');var rs=require(_0x3151('0x2'));var fs=require('fs');var Redis=require(_0x3151('0x3'));var db=require(_0x3151('0x4'))['db'];var utils=require(_0x3151('0x5'));var logger=require('../../config/logger')(_0x3151('0x6'));var config=require(_0x3151('0x7'));var jayson=require(_0x3151('0x8'));var client=jayson[_0x3151('0x9')][_0x3151('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4dc1c3,_0x424a19,_0x2d6dc9){return new BPromise(function(_0x49457f,_0x25cd77){return client[_0x3151('0xb')](_0x4dc1c3,_0x2d6dc9)[_0x3151('0xc')](function(_0x4ccf04){logger[_0x3151('0xd')](_0x3151('0xe'),_0x424a19,_0x3151('0xf'));logger[_0x3151('0x10')](_0x3151('0x11'),_0x424a19,'request\x20sent',JSON[_0x3151('0x12')](_0x4ccf04));if(_0x4ccf04[_0x3151('0x13')]){if(_0x4ccf04['error'][_0x3151('0x14')]===0x1f4){logger[_0x3151('0x13')](_0x3151('0xe'),_0x424a19,_0x4ccf04[_0x3151('0x13')][_0x3151('0x15')]);return _0x25cd77(_0x4ccf04[_0x3151('0x13')][_0x3151('0x15')]);}logger[_0x3151('0x13')](_0x3151('0xe'),_0x424a19,_0x4ccf04['error']['message']);return _0x49457f(_0x4ccf04[_0x3151('0x13')]['message']);}else{logger[_0x3151('0xd')](_0x3151('0xe'),_0x424a19,_0x3151('0xf'));_0x49457f(_0x4ccf04[_0x3151('0x16')][_0x3151('0x15')]);}})[_0x3151('0x17')](function(_0x4557d2){logger[_0x3151('0x13')](_0x3151('0xe'),_0x424a19,_0x4557d2);_0x25cd77(_0x4557d2);});});}exports[_0x3151('0x18')]=function(_0x146c57){var _0x1d3704=this;return new Promise(function(_0x266ac5,_0x92466a){return db['Setting'][_0x3151('0x19')]({'raw':_0x146c57['options']?_0x146c57[_0x3151('0x1a')][_0x3151('0x1b')]===undefined?!![]:![]:!![],'where':_0x146c57['options']?_0x146c57[_0x3151('0x1a')]['where']||null:null,'attributes':_0x146c57[_0x3151('0x1a')]?_0x146c57[_0x3151('0x1a')][_0x3151('0x1c')]||null:null,'include':_0x146c57['options']?_0x146c57['options']['include']?_[_0x3151('0x1d')](_0x146c57[_0x3151('0x1a')][_0x3151('0x1e')],function(_0x5edc86){return{'model':db[_0x5edc86['model']],'as':_0x5edc86['as'],'attributes':_0x5edc86['attributes'],'include':_0x5edc86['include']?_[_0x3151('0x1d')](_0x5edc86[_0x3151('0x1e')],function(_0x423217){return{'model':db[_0x423217[_0x3151('0x1f')]],'as':_0x423217['as'],'attributes':_0x423217[_0x3151('0x1c')],'include':_0x423217[_0x3151('0x1e')]?_[_0x3151('0x1d')](_0x423217['include'],function(_0x381248){return{'model':db[_0x381248[_0x3151('0x1f')]],'as':_0x381248['as'],'attributes':_0x381248[_0x3151('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1f32b8){logger[_0x3151('0xd')](_0x3151('0x18'),_0x146c57);logger['debug']('ShowSetting',_0x146c57,JSON['stringify'](_0x1f32b8));_0x266ac5(_0x1f32b8);})[_0x3151('0x17')](function(_0x4b6087){logger[_0x3151('0x13')](_0x3151('0x18'),_0x4b6087[_0x3151('0x15')],_0x146c57);_0x92466a(_0x1d3704[_0x3151('0x13')](0x1f4,_0x4b6087[_0x3151('0x15')]));});});};