Built motion from commit (unavailable).|2.5.11
[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 _0x4e34=['randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./squareProject.socket','register','then','info','SquareProject,\x20%s,\x20%s','request\x20sent','debug','SquareProject,\x20%s,\x20%s,\x20%s','error','code','message','result','ShowSquareProject','SquareProject','find','options','where','include','map','attributes','model','lodash','bluebird'];(function(_0x19d66c,_0x42e86d){var _0x2d0faf=function(_0x134f57){while(--_0x134f57){_0x19d66c['push'](_0x19d66c['shift']());}};_0x2d0faf(++_0x42e86d);}(_0x4e34,0x8e));var _0x44e3=function(_0x5329c3,_0x419bcf){_0x5329c3=_0x5329c3-0x0;var _0x2689c4=_0x4e34[_0x5329c3];return _0x2689c4;};'use strict';var _=require(_0x44e3('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x44e3('0x1'));var rs=require(_0x44e3('0x2'));var fs=require('fs');var Redis=require(_0x44e3('0x3'));var db=require(_0x44e3('0x4'))['db'];var utils=require(_0x44e3('0x5'));var logger=require(_0x44e3('0x6'))('rpc');var config=require(_0x44e3('0x7'));var jayson=require(_0x44e3('0x8'));var client=jayson[_0x44e3('0x9')][_0x44e3('0xa')]({'port':0x232a});config[_0x44e3('0xb')]=_[_0x44e3('0xc')](config[_0x44e3('0xb')],{'host':_0x44e3('0xd'),'port':0x18eb});var socket=require(_0x44e3('0xe'))(new Redis(config[_0x44e3('0xb')]));require(_0x44e3('0xf'))[_0x44e3('0x10')](socket);function respondWithRpcPromise(_0x2e1826,_0x4321ff,_0x2773cd){return new BPromise(function(_0x1c14e9,_0x3b8e80){return client['request'](_0x2e1826,_0x2773cd)[_0x44e3('0x11')](function(_0x1fe12e){logger[_0x44e3('0x12')](_0x44e3('0x13'),_0x4321ff,_0x44e3('0x14'));logger[_0x44e3('0x15')](_0x44e3('0x16'),_0x4321ff,_0x44e3('0x14'),JSON['stringify'](_0x1fe12e));if(_0x1fe12e[_0x44e3('0x17')]){if(_0x1fe12e[_0x44e3('0x17')][_0x44e3('0x18')]===0x1f4){logger[_0x44e3('0x17')]('SquareProject,\x20%s,\x20%s',_0x4321ff,_0x1fe12e[_0x44e3('0x17')][_0x44e3('0x19')]);return _0x3b8e80(_0x1fe12e[_0x44e3('0x17')][_0x44e3('0x19')]);}logger[_0x44e3('0x17')](_0x44e3('0x13'),_0x4321ff,_0x1fe12e[_0x44e3('0x17')][_0x44e3('0x19')]);return _0x1c14e9(_0x1fe12e[_0x44e3('0x17')][_0x44e3('0x19')]);}else{logger[_0x44e3('0x12')]('SquareProject,\x20%s,\x20%s',_0x4321ff,_0x44e3('0x14'));_0x1c14e9(_0x1fe12e[_0x44e3('0x1a')][_0x44e3('0x19')]);}})['catch'](function(_0x3dfb36){logger[_0x44e3('0x17')]('SquareProject,\x20%s,\x20%s',_0x4321ff,_0x3dfb36);_0x3b8e80(_0x3dfb36);});});}exports[_0x44e3('0x1b')]=function(_0x525f8c){var _0x6b3166=this;return new Promise(function(_0x11c14e,_0x2c7f0c){return db[_0x44e3('0x1c')][_0x44e3('0x1d')]({'raw':_0x525f8c[_0x44e3('0x1e')]?_0x525f8c[_0x44e3('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x525f8c[_0x44e3('0x1e')]?_0x525f8c[_0x44e3('0x1e')][_0x44e3('0x1f')]||null:null,'attributes':_0x525f8c[_0x44e3('0x1e')]?_0x525f8c[_0x44e3('0x1e')]['attributes']||null:null,'include':_0x525f8c[_0x44e3('0x1e')]?_0x525f8c['options'][_0x44e3('0x20')]?_[_0x44e3('0x21')](_0x525f8c['options']['include'],function(_0x27d8b9){return{'model':db[_0x27d8b9['model']],'as':_0x27d8b9['as'],'attributes':_0x27d8b9[_0x44e3('0x22')],'include':_0x27d8b9[_0x44e3('0x20')]?_[_0x44e3('0x21')](_0x27d8b9[_0x44e3('0x20')],function(_0x237341){return{'model':db[_0x237341[_0x44e3('0x23')]],'as':_0x237341['as'],'attributes':_0x237341[_0x44e3('0x22')],'include':_0x237341[_0x44e3('0x20')]?_[_0x44e3('0x21')](_0x237341[_0x44e3('0x20')],function(_0x17eb98){return{'model':db[_0x17eb98[_0x44e3('0x23')]],'as':_0x17eb98['as'],'attributes':_0x17eb98['attributes']};}):[]};}):[]};}):[]:[]})[_0x44e3('0x11')](function(_0x4cfee6){logger[_0x44e3('0x12')](_0x44e3('0x1b'),_0x525f8c);logger[_0x44e3('0x15')](_0x44e3('0x1b'),_0x525f8c,JSON['stringify'](_0x4cfee6));_0x11c14e(_0x4cfee6);})['catch'](function(_0x592de2){logger['error']('ShowSquareProject',_0x592de2[_0x44e3('0x19')],_0x525f8c);_0x2c7f0c(_0x6b3166[_0x44e3('0x17')](0x1f4,_0x592de2['message']));});});};