a16c8de605bc1fcc0d531cc07ea911e7ef248db5
[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 _0xf0fb=['where','attributes','map','model','include','ShowSquareProject','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./squareProject.socket','register','request','then','info','request\x20sent','debug','stringify','error','code','SquareProject,\x20%s,\x20%s','message','catch','SquareProject','options'];(function(_0x28579a,_0x13e3df){var _0xc5ab3=function(_0x54b732){while(--_0x54b732){_0x28579a['push'](_0x28579a['shift']());}};_0xc5ab3(++_0x13e3df);}(_0xf0fb,0x72));var _0xbf0f=function(_0x279095,_0x15f37e){_0x279095=_0x279095-0x0;var _0x5a5cdb=_0xf0fb[_0x279095];return _0x5a5cdb;};'use strict';var _=require(_0xbf0f('0x0'));var util=require(_0xbf0f('0x1'));var moment=require(_0xbf0f('0x2'));var BPromise=require('bluebird');var rs=require(_0xbf0f('0x3'));var fs=require('fs');var Redis=require(_0xbf0f('0x4'));var db=require(_0xbf0f('0x5'))['db'];var utils=require(_0xbf0f('0x6'));var logger=require('../../config/logger')(_0xbf0f('0x7'));var config=require(_0xbf0f('0x8'));var jayson=require(_0xbf0f('0x9'));var client=jayson[_0xbf0f('0xa')]['http']({'port':0x232a});config['redis']=_[_0xbf0f('0xb')](config[_0xbf0f('0xc')],{'host':_0xbf0f('0xd'),'port':0x18eb});var socket=require(_0xbf0f('0xe'))(new Redis(config[_0xbf0f('0xc')]));require(_0xbf0f('0xf'))[_0xbf0f('0x10')](socket);function respondWithRpcPromise(_0x476d4e,_0x280494,_0x500e50){return new BPromise(function(_0x17d307,_0x297cc3){return client[_0xbf0f('0x11')](_0x476d4e,_0x500e50)[_0xbf0f('0x12')](function(_0x577f01){logger[_0xbf0f('0x13')]('SquareProject,\x20%s,\x20%s',_0x280494,_0xbf0f('0x14'));logger[_0xbf0f('0x15')]('SquareProject,\x20%s,\x20%s,\x20%s',_0x280494,_0xbf0f('0x14'),JSON[_0xbf0f('0x16')](_0x577f01));if(_0x577f01[_0xbf0f('0x17')]){if(_0x577f01[_0xbf0f('0x17')][_0xbf0f('0x18')]===0x1f4){logger[_0xbf0f('0x17')](_0xbf0f('0x19'),_0x280494,_0x577f01[_0xbf0f('0x17')][_0xbf0f('0x1a')]);return _0x297cc3(_0x577f01[_0xbf0f('0x17')]['message']);}logger[_0xbf0f('0x17')](_0xbf0f('0x19'),_0x280494,_0x577f01[_0xbf0f('0x17')][_0xbf0f('0x1a')]);return _0x17d307(_0x577f01[_0xbf0f('0x17')][_0xbf0f('0x1a')]);}else{logger[_0xbf0f('0x13')](_0xbf0f('0x19'),_0x280494,'request\x20sent');_0x17d307(_0x577f01['result'][_0xbf0f('0x1a')]);}})[_0xbf0f('0x1b')](function(_0x22c8aa){logger[_0xbf0f('0x17')](_0xbf0f('0x19'),_0x280494,_0x22c8aa);_0x297cc3(_0x22c8aa);});});}exports['ShowSquareProject']=function(_0x48023b){var _0x98a482=this;return new Promise(function(_0x4f1bf3,_0x15c135){return db[_0xbf0f('0x1c')]['find']({'raw':_0x48023b[_0xbf0f('0x1d')]?_0x48023b[_0xbf0f('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x48023b['options']?_0x48023b['options'][_0xbf0f('0x1e')]||null:null,'attributes':_0x48023b[_0xbf0f('0x1d')]?_0x48023b[_0xbf0f('0x1d')][_0xbf0f('0x1f')]||null:null,'include':_0x48023b[_0xbf0f('0x1d')]?_0x48023b[_0xbf0f('0x1d')]['include']?_[_0xbf0f('0x20')](_0x48023b[_0xbf0f('0x1d')]['include'],function(_0x2a3943){return{'model':db[_0x2a3943[_0xbf0f('0x21')]],'as':_0x2a3943['as'],'attributes':_0x2a3943[_0xbf0f('0x1f')],'include':_0x2a3943['include']?_[_0xbf0f('0x20')](_0x2a3943[_0xbf0f('0x22')],function(_0x29c635){return{'model':db[_0x29c635[_0xbf0f('0x21')]],'as':_0x29c635['as'],'attributes':_0x29c635[_0xbf0f('0x1f')],'include':_0x29c635['include']?_[_0xbf0f('0x20')](_0x29c635[_0xbf0f('0x22')],function(_0x392b0e){return{'model':db[_0x392b0e['model']],'as':_0x392b0e['as'],'attributes':_0x392b0e[_0xbf0f('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xbf0f('0x12')](function(_0x1692e4){logger[_0xbf0f('0x13')](_0xbf0f('0x23'),_0x48023b);logger[_0xbf0f('0x15')](_0xbf0f('0x23'),_0x48023b,JSON[_0xbf0f('0x16')](_0x1692e4));_0x4f1bf3(_0x1692e4);})['catch'](function(_0x5131e6){logger[_0xbf0f('0x17')](_0xbf0f('0x23'),_0x5131e6[_0xbf0f('0x1a')],_0x48023b);_0x15c135(_0x98a482[_0xbf0f('0x17')](0x1f4,_0x5131e6['message']));});});};