5aff1d5b396686f472cd7d98d8b6e6fa975702be
[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 _0xf2ee=['where','limit','include','map','model','attributes','then','info','stringify','catch','error','message','ShowSquareProject','find','debug','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','redis','./squareProject.socket','register','GetSquareProjects','SquareProject','options'];(function(_0x4ff886,_0x55070a){var _0x55b548=function(_0xac2e79){while(--_0xac2e79){_0x4ff886['push'](_0x4ff886['shift']());}};_0x55b548(++_0x55070a);}(_0xf2ee,0x195));var _0xef2e=function(_0xc19184,_0xa682b2){_0xc19184=_0xc19184-0x0;var _0x3149ac=_0xf2ee[_0xc19184];return _0x3149ac;};'use strict';var _=require('lodash');var Redis=require(_0xef2e('0x0'));var db=require(_0xef2e('0x1'))['db'];var logger=require(_0xef2e('0x2'))(_0xef2e('0x3'));var config=require(_0xef2e('0x4'));config[_0xef2e('0x5')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xef2e('0x5')]));require(_0xef2e('0x6'))[_0xef2e('0x7')](socket);exports[_0xef2e('0x8')]=function(_0x3abb70){var _0x25dacb=this;return new Promise(function(_0x228264,_0x1ac549){return db[_0xef2e('0x9')]['findAll']({'raw':_0x3abb70[_0xef2e('0xa')]?_0x3abb70['options']['raw']===undefined?!![]:![]:!![],'where':_0x3abb70[_0xef2e('0xa')]?_0x3abb70[_0xef2e('0xa')][_0xef2e('0xb')]||null:null,'attributes':_0x3abb70['options']?_0x3abb70[_0xef2e('0xa')]['attributes']||null:null,'limit':_0x3abb70[_0xef2e('0xa')]?_0x3abb70[_0xef2e('0xa')][_0xef2e('0xc')]||null:null,'include':_0x3abb70['options']?_0x3abb70[_0xef2e('0xa')][_0xef2e('0xd')]?_[_0xef2e('0xe')](_0x3abb70[_0xef2e('0xa')]['include'],function(_0x30f6cf){return{'model':db[_0x30f6cf[_0xef2e('0xf')]],'as':_0x30f6cf['as'],'attributes':_0x30f6cf[_0xef2e('0x10')],'include':_0x30f6cf['include']?_[_0xef2e('0xe')](_0x30f6cf['include'],function(_0x37891a){return{'model':db[_0x37891a['model']],'as':_0x37891a['as'],'attributes':_0x37891a[_0xef2e('0x10')],'include':_0x37891a[_0xef2e('0xd')]?_[_0xef2e('0xe')](_0x37891a['include'],function(_0x11836e){return{'model':db[_0x11836e[_0xef2e('0xf')]],'as':_0x11836e['as'],'attributes':_0x11836e['attributes']};}):[]};}):[]};}):[]:[]})[_0xef2e('0x11')](function(_0x2e79a5){logger[_0xef2e('0x12')](_0xef2e('0x8'),_0x3abb70);logger['debug'](_0xef2e('0x8'),_0x3abb70,JSON[_0xef2e('0x13')](_0x2e79a5));_0x228264(_0x2e79a5);})[_0xef2e('0x14')](function(_0x4c8d73){logger[_0xef2e('0x15')](_0xef2e('0x8'),_0x4c8d73[_0xef2e('0x16')],_0x3abb70);_0x1ac549(_0x25dacb[_0xef2e('0x15')](0x1f4,_0x4c8d73[_0xef2e('0x16')]));});});};exports[_0xef2e('0x17')]=function(_0x527564){var _0x4438d1=this;return new Promise(function(_0xf5d068,_0x182146){return db['SquareProject'][_0xef2e('0x18')]({'raw':_0x527564[_0xef2e('0xa')]?_0x527564[_0xef2e('0xa')]['raw']===undefined?!![]:![]:!![],'where':_0x527564[_0xef2e('0xa')]?_0x527564[_0xef2e('0xa')][_0xef2e('0xb')]||null:null,'attributes':_0x527564[_0xef2e('0xa')]?_0x527564[_0xef2e('0xa')][_0xef2e('0x10')]||null:null,'include':_0x527564[_0xef2e('0xa')]?_0x527564['options']['include']?_[_0xef2e('0xe')](_0x527564['options'][_0xef2e('0xd')],function(_0x327e67){return{'model':db[_0x327e67[_0xef2e('0xf')]],'as':_0x327e67['as'],'attributes':_0x327e67[_0xef2e('0x10')],'include':_0x327e67['include']?_[_0xef2e('0xe')](_0x327e67[_0xef2e('0xd')],function(_0x36397c){return{'model':db[_0x36397c[_0xef2e('0xf')]],'as':_0x36397c['as'],'attributes':_0x36397c['attributes'],'include':_0x36397c[_0xef2e('0xd')]?_[_0xef2e('0xe')](_0x36397c[_0xef2e('0xd')],function(_0x49a5bc){return{'model':db[_0x49a5bc['model']],'as':_0x49a5bc['as'],'attributes':_0x49a5bc[_0xef2e('0x10')]};}):[]};}):[]};}):[]:[]})[_0xef2e('0x11')](function(_0x448b83){logger[_0xef2e('0x12')]('ShowSquareProject',_0x527564);logger[_0xef2e('0x19')](_0xef2e('0x17'),_0x527564,JSON[_0xef2e('0x13')](_0x448b83));_0xf5d068(_0x448b83);})['catch'](function(_0xa91baa){logger[_0xef2e('0x15')](_0xef2e('0x17'),_0xa91baa[_0xef2e('0x16')],_0x527564);_0x182146(_0x4438d1['error'](0x1f4,_0xa91baa[_0xef2e('0x16')]));});});};