Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / squareProject / squareProject.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 _0x142e=['then','info','stringify','catch','message','error','find','ShowSquareProject','lodash','../../config/logger','../../config/environment','redis','localhost','socket.io-emitter','./squareProject.socket','register','GetSquareProjects','SquareProject','findAll','options','raw','where','limit','include','map','model','attributes'];(function(_0x38ed42,_0x3d9a37){var _0x474931=function(_0x1fa601){while(--_0x1fa601){_0x38ed42['push'](_0x38ed42['shift']());}};_0x474931(++_0x3d9a37);}(_0x142e,0x19d));var _0xe142=function(_0x1752e0,_0x28cb20){_0x1752e0=_0x1752e0-0x0;var _0x161566=_0x142e[_0x1752e0];return _0x161566;};'use strict';var _=require(_0xe142('0x0'));var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var logger=require(_0xe142('0x1'))('rpc');var config=require(_0xe142('0x2'));config[_0xe142('0x3')]=_['defaults'](config[_0xe142('0x3')],{'host':_0xe142('0x4'),'port':0x18eb});var socket=require(_0xe142('0x5'))(new Redis(config[_0xe142('0x3')]));require(_0xe142('0x6'))[_0xe142('0x7')](socket);exports[_0xe142('0x8')]=function(_0x54a504){var _0x52725b=this;return new Promise(function(_0x27b89e,_0x4acd71){return db[_0xe142('0x9')][_0xe142('0xa')]({'raw':_0x54a504[_0xe142('0xb')]?_0x54a504[_0xe142('0xb')][_0xe142('0xc')]===undefined?!![]:![]:!![],'where':_0x54a504[_0xe142('0xb')]?_0x54a504[_0xe142('0xb')][_0xe142('0xd')]||null:null,'attributes':_0x54a504[_0xe142('0xb')]?_0x54a504[_0xe142('0xb')]['attributes']||null:null,'limit':_0x54a504[_0xe142('0xb')]?_0x54a504['options'][_0xe142('0xe')]||null:null,'include':_0x54a504[_0xe142('0xb')]?_0x54a504[_0xe142('0xb')][_0xe142('0xf')]?_[_0xe142('0x10')](_0x54a504[_0xe142('0xb')][_0xe142('0xf')],function(_0x397b95){return{'model':db[_0x397b95[_0xe142('0x11')]],'as':_0x397b95['as'],'attributes':_0x397b95['attributes'],'include':_0x397b95[_0xe142('0xf')]?_['map'](_0x397b95[_0xe142('0xf')],function(_0x42f2bf){return{'model':db[_0x42f2bf['model']],'as':_0x42f2bf['as'],'attributes':_0x42f2bf[_0xe142('0x12')],'include':_0x42f2bf[_0xe142('0xf')]?_[_0xe142('0x10')](_0x42f2bf[_0xe142('0xf')],function(_0x146806){return{'model':db[_0x146806[_0xe142('0x11')]],'as':_0x146806['as'],'attributes':_0x146806['attributes']};}):[]};}):[]};}):[]:[]})[_0xe142('0x13')](function(_0xdd25f0){logger[_0xe142('0x14')](_0xe142('0x8'),_0x54a504);logger['debug'](_0xe142('0x8'),_0x54a504,JSON[_0xe142('0x15')](_0xdd25f0));_0x27b89e(_0xdd25f0);})[_0xe142('0x16')](function(_0x3eb32d){logger['error'](_0xe142('0x8'),_0x3eb32d[_0xe142('0x17')],_0x54a504);_0x4acd71(_0x52725b[_0xe142('0x18')](0x1f4,_0x3eb32d[_0xe142('0x17')]));});});};exports['ShowSquareProject']=function(_0x2b5bbd){var _0x169062=this;return new Promise(function(_0x5150fa,_0x23fa6f){return db[_0xe142('0x9')][_0xe142('0x19')]({'raw':_0x2b5bbd[_0xe142('0xb')]?_0x2b5bbd[_0xe142('0xb')][_0xe142('0xc')]===undefined?!![]:![]:!![],'where':_0x2b5bbd[_0xe142('0xb')]?_0x2b5bbd['options'][_0xe142('0xd')]||null:null,'attributes':_0x2b5bbd['options']?_0x2b5bbd[_0xe142('0xb')][_0xe142('0x12')]||null:null,'include':_0x2b5bbd[_0xe142('0xb')]?_0x2b5bbd[_0xe142('0xb')][_0xe142('0xf')]?_['map'](_0x2b5bbd['options']['include'],function(_0xc6963e){return{'model':db[_0xc6963e[_0xe142('0x11')]],'as':_0xc6963e['as'],'attributes':_0xc6963e['attributes'],'include':_0xc6963e[_0xe142('0xf')]?_[_0xe142('0x10')](_0xc6963e[_0xe142('0xf')],function(_0x544418){return{'model':db[_0x544418[_0xe142('0x11')]],'as':_0x544418['as'],'attributes':_0x544418[_0xe142('0x12')],'include':_0x544418[_0xe142('0xf')]?_['map'](_0x544418[_0xe142('0xf')],function(_0x5daf95){return{'model':db[_0x5daf95[_0xe142('0x11')]],'as':_0x5daf95['as'],'attributes':_0x5daf95[_0xe142('0x12')]};}):[]};}):[]};}):[]:[]})[_0xe142('0x13')](function(_0x443759){logger['info'](_0xe142('0x1a'),_0x2b5bbd);logger['debug'](_0xe142('0x1a'),_0x2b5bbd,JSON['stringify'](_0x443759));_0x5150fa(_0x443759);})['catch'](function(_0x5b905f){logger[_0xe142('0x18')]('ShowSquareProject',_0x5b905f[_0xe142('0x17')],_0x2b5bbd);_0x23fa6f(_0x169062['error'](0x1f4,_0x5b905f[_0xe142('0x17')]));});});};