f8bfefa923841ea1630971a86743998b3634e637
[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 _0x5bf3=['http','redis','localhost','./squareProject.socket','register','then','info','SquareProject,\x20%s,\x20%s','request\x20sent','debug','error','message','result','catch','find','options','raw','include','map','model','attributes','ShowSquareProject','stringify','lodash','util','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client'];(function(_0x5b57d4,_0x58b01b){var _0x28400f=function(_0x394cfd){while(--_0x394cfd){_0x5b57d4['push'](_0x5b57d4['shift']());}};_0x28400f(++_0x58b01b);}(_0x5bf3,0x1e8));var _0x35bf=function(_0x4c5c95,_0x389b35){_0x4c5c95=_0x4c5c95-0x0;var _0x261209=_0x5bf3[_0x4c5c95];return _0x261209;};'use strict';var _=require(_0x35bf('0x0'));var util=require(_0x35bf('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x35bf('0x2'));var fs=require('fs');var Redis=require(_0x35bf('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x35bf('0x4'))('rpc');var config=require(_0x35bf('0x5'));var jayson=require(_0x35bf('0x6'));var client=jayson[_0x35bf('0x7')][_0x35bf('0x8')]({'port':0x232a});config['redis']=_['defaults'](config[_0x35bf('0x9')],{'host':_0x35bf('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x35bf('0x9')]));require(_0x35bf('0xb'))[_0x35bf('0xc')](socket);function respondWithRpcPromise(_0xe1b32a,_0x21dcb4,_0x55b8f0){return new BPromise(function(_0x3c8b1b,_0x453f24){return client['request'](_0xe1b32a,_0x55b8f0)[_0x35bf('0xd')](function(_0x3b8fb5){logger[_0x35bf('0xe')](_0x35bf('0xf'),_0x21dcb4,_0x35bf('0x10'));logger[_0x35bf('0x11')]('SquareProject,\x20%s,\x20%s,\x20%s',_0x21dcb4,_0x35bf('0x10'),JSON['stringify'](_0x3b8fb5));if(_0x3b8fb5[_0x35bf('0x12')]){if(_0x3b8fb5[_0x35bf('0x12')]['code']===0x1f4){logger[_0x35bf('0x12')](_0x35bf('0xf'),_0x21dcb4,_0x3b8fb5[_0x35bf('0x12')][_0x35bf('0x13')]);return _0x453f24(_0x3b8fb5[_0x35bf('0x12')][_0x35bf('0x13')]);}logger['error'](_0x35bf('0xf'),_0x21dcb4,_0x3b8fb5[_0x35bf('0x12')][_0x35bf('0x13')]);return _0x3c8b1b(_0x3b8fb5['error']['message']);}else{logger['info'](_0x35bf('0xf'),_0x21dcb4,_0x35bf('0x10'));_0x3c8b1b(_0x3b8fb5[_0x35bf('0x14')][_0x35bf('0x13')]);}})[_0x35bf('0x15')](function(_0x2679df){logger[_0x35bf('0x12')](_0x35bf('0xf'),_0x21dcb4,_0x2679df);_0x453f24(_0x2679df);});});}exports['ShowSquareProject']=function(_0x3e2a0a){var _0x329213=this;return new Promise(function(_0x56fb41,_0x3c4581){return db['SquareProject'][_0x35bf('0x16')]({'raw':_0x3e2a0a[_0x35bf('0x17')]?_0x3e2a0a[_0x35bf('0x17')][_0x35bf('0x18')]===undefined?!![]:![]:!![],'where':_0x3e2a0a[_0x35bf('0x17')]?_0x3e2a0a[_0x35bf('0x17')]['where']||null:null,'attributes':_0x3e2a0a[_0x35bf('0x17')]?_0x3e2a0a[_0x35bf('0x17')]['attributes']||null:null,'include':_0x3e2a0a[_0x35bf('0x17')]?_0x3e2a0a[_0x35bf('0x17')][_0x35bf('0x19')]?_[_0x35bf('0x1a')](_0x3e2a0a[_0x35bf('0x17')][_0x35bf('0x19')],function(_0x3a159b){return{'model':db[_0x3a159b[_0x35bf('0x1b')]],'as':_0x3a159b['as'],'attributes':_0x3a159b[_0x35bf('0x1c')],'include':_0x3a159b[_0x35bf('0x19')]?_['map'](_0x3a159b[_0x35bf('0x19')],function(_0x180e7c){return{'model':db[_0x180e7c[_0x35bf('0x1b')]],'as':_0x180e7c['as'],'attributes':_0x180e7c[_0x35bf('0x1c')],'include':_0x180e7c['include']?_[_0x35bf('0x1a')](_0x180e7c['include'],function(_0x108086){return{'model':db[_0x108086[_0x35bf('0x1b')]],'as':_0x108086['as'],'attributes':_0x108086[_0x35bf('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x35bf('0xd')](function(_0x144efb){logger[_0x35bf('0xe')](_0x35bf('0x1d'),_0x3e2a0a);logger[_0x35bf('0x11')](_0x35bf('0x1d'),_0x3e2a0a,JSON[_0x35bf('0x1e')](_0x144efb));_0x56fb41(_0x144efb);})[_0x35bf('0x15')](function(_0xfe2503){logger[_0x35bf('0x12')](_0x35bf('0x1d'),_0xfe2503[_0x35bf('0x13')],_0x3e2a0a);_0x3c4581(_0x329213['error'](0x1f4,_0xfe2503[_0x35bf('0x13')]));});});};