Built motion from commit 0555bc41.|2.5.41
[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 _0x9915=['socket.io-emitter','./squareProject.socket','request','info','SquareProject,\x20%s,\x20%s','request\x20sent','debug','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSquareProject','raw','options','attributes','include','map','model','then','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','defaults','redis'];(function(_0x4ddfee,_0x18d7e6){var _0x1c98bf=function(_0x2a2993){while(--_0x2a2993){_0x4ddfee['push'](_0x4ddfee['shift']());}};_0x1c98bf(++_0x18d7e6);}(_0x9915,0x15a));var _0x5991=function(_0x5709e0,_0x16e841){_0x5709e0=_0x5709e0-0x0;var _0x2bb2b7=_0x9915[_0x5709e0];return _0x2bb2b7;};'use strict';var _=require(_0x5991('0x0'));var util=require(_0x5991('0x1'));var moment=require(_0x5991('0x2'));var BPromise=require(_0x5991('0x3'));var rs=require(_0x5991('0x4'));var fs=require('fs');var Redis=require(_0x5991('0x5'));var db=require(_0x5991('0x6'))['db'];var utils=require(_0x5991('0x7'));var logger=require(_0x5991('0x8'))('rpc');var config=require('../../config/environment');var jayson=require(_0x5991('0x9'));var client=jayson[_0x5991('0xa')][_0x5991('0xb')]({'port':0x232a});config['redis']=_[_0x5991('0xc')](config[_0x5991('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0x5991('0xe'))(new Redis(config[_0x5991('0xd')]));require(_0x5991('0xf'))['register'](socket);function respondWithRpcPromise(_0x4a8f52,_0x4f6def,_0x5389c9){return new BPromise(function(_0x2060df,_0x20c81a){return client[_0x5991('0x10')](_0x4a8f52,_0x5389c9)['then'](function(_0x55ae46){logger[_0x5991('0x11')](_0x5991('0x12'),_0x4f6def,_0x5991('0x13'));logger[_0x5991('0x14')](_0x5991('0x15'),_0x4f6def,'request\x20sent',JSON[_0x5991('0x16')](_0x55ae46));if(_0x55ae46[_0x5991('0x17')]){if(_0x55ae46[_0x5991('0x17')][_0x5991('0x18')]===0x1f4){logger[_0x5991('0x17')](_0x5991('0x12'),_0x4f6def,_0x55ae46[_0x5991('0x17')][_0x5991('0x19')]);return _0x20c81a(_0x55ae46[_0x5991('0x17')][_0x5991('0x19')]);}logger[_0x5991('0x17')]('SquareProject,\x20%s,\x20%s',_0x4f6def,_0x55ae46[_0x5991('0x17')][_0x5991('0x19')]);return _0x2060df(_0x55ae46[_0x5991('0x17')][_0x5991('0x19')]);}else{logger['info'](_0x5991('0x12'),_0x4f6def,_0x5991('0x13'));_0x2060df(_0x55ae46[_0x5991('0x1a')]['message']);}})[_0x5991('0x1b')](function(_0x15f3be){logger[_0x5991('0x17')]('SquareProject,\x20%s,\x20%s',_0x4f6def,_0x15f3be);_0x20c81a(_0x15f3be);});});}exports[_0x5991('0x1c')]=function(_0x12ea20){var _0x1205b9=this;return new Promise(function(_0x366d92,_0x4ecd76){return db['SquareProject']['find']({'raw':_0x12ea20['options']?_0x12ea20['options'][_0x5991('0x1d')]===undefined?!![]:![]:!![],'where':_0x12ea20[_0x5991('0x1e')]?_0x12ea20[_0x5991('0x1e')]['where']||null:null,'attributes':_0x12ea20[_0x5991('0x1e')]?_0x12ea20['options'][_0x5991('0x1f')]||null:null,'include':_0x12ea20[_0x5991('0x1e')]?_0x12ea20['options'][_0x5991('0x20')]?_[_0x5991('0x21')](_0x12ea20[_0x5991('0x1e')][_0x5991('0x20')],function(_0x3a0655){return{'model':db[_0x3a0655[_0x5991('0x22')]],'as':_0x3a0655['as'],'attributes':_0x3a0655[_0x5991('0x1f')],'include':_0x3a0655[_0x5991('0x20')]?_[_0x5991('0x21')](_0x3a0655['include'],function(_0x1ad3bb){return{'model':db[_0x1ad3bb[_0x5991('0x22')]],'as':_0x1ad3bb['as'],'attributes':_0x1ad3bb[_0x5991('0x1f')],'include':_0x1ad3bb[_0x5991('0x20')]?_[_0x5991('0x21')](_0x1ad3bb[_0x5991('0x20')],function(_0x41106d){return{'model':db[_0x41106d['model']],'as':_0x41106d['as'],'attributes':_0x41106d[_0x5991('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x5991('0x23')](function(_0xb4f914){logger[_0x5991('0x11')]('ShowSquareProject',_0x12ea20);logger[_0x5991('0x14')](_0x5991('0x1c'),_0x12ea20,JSON[_0x5991('0x16')](_0xb4f914));_0x366d92(_0xb4f914);})[_0x5991('0x1b')](function(_0x46712a){logger['error']('ShowSquareProject',_0x46712a[_0x5991('0x19')],_0x12ea20);_0x4ecd76(_0x1205b9['error'](0x1f4,_0x46712a[_0x5991('0x19')]));});});};