Built motion from commit (unavailable).|2.5.4
[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 _0x817a=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./squareProject.socket','request','then','SquareProject,\x20%s,\x20%s','request\x20sent','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSquareProject','SquareProject','find','options','attributes','map','include','model','lodash','util','moment','ioredis'];(function(_0x1fcaf1,_0x21c3c2){var _0x55f464=function(_0x348eb3){while(--_0x348eb3){_0x1fcaf1['push'](_0x1fcaf1['shift']());}};_0x55f464(++_0x21c3c2);}(_0x817a,0x7c));var _0xa817=function(_0x4da016,_0x4e4e6a){_0x4da016=_0x4da016-0x0;var _0x216051=_0x817a[_0x4da016];return _0x216051;};'use strict';var _=require(_0xa817('0x0'));var util=require(_0xa817('0x1'));var moment=require(_0xa817('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa817('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xa817('0x4'))(_0xa817('0x5'));var config=require(_0xa817('0x6'));var jayson=require(_0xa817('0x7'));var client=jayson[_0xa817('0x8')][_0xa817('0x9')]({'port':0x232a});config[_0xa817('0xa')]=_['defaults'](config[_0xa817('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xa817('0xb'))(new Redis(config[_0xa817('0xa')]));require(_0xa817('0xc'))['register'](socket);function respondWithRpcPromise(_0x3d5364,_0x1378df,_0x17ef69){return new BPromise(function(_0x59e9e7,_0x35acad){return client[_0xa817('0xd')](_0x3d5364,_0x17ef69)[_0xa817('0xe')](function(_0x2257d9){logger['info'](_0xa817('0xf'),_0x1378df,_0xa817('0x10'));logger['debug'](_0xa817('0x11'),_0x1378df,'request\x20sent',JSON[_0xa817('0x12')](_0x2257d9));if(_0x2257d9[_0xa817('0x13')]){if(_0x2257d9[_0xa817('0x13')][_0xa817('0x14')]===0x1f4){logger[_0xa817('0x13')](_0xa817('0xf'),_0x1378df,_0x2257d9['error'][_0xa817('0x15')]);return _0x35acad(_0x2257d9[_0xa817('0x13')]['message']);}logger[_0xa817('0x13')](_0xa817('0xf'),_0x1378df,_0x2257d9['error']['message']);return _0x59e9e7(_0x2257d9[_0xa817('0x13')][_0xa817('0x15')]);}else{logger['info'](_0xa817('0xf'),_0x1378df,_0xa817('0x10'));_0x59e9e7(_0x2257d9[_0xa817('0x16')]['message']);}})[_0xa817('0x17')](function(_0x4d1fd8){logger[_0xa817('0x13')](_0xa817('0xf'),_0x1378df,_0x4d1fd8);_0x35acad(_0x4d1fd8);});});}exports[_0xa817('0x18')]=function(_0x1abe0b){var _0x5bb9fa=this;return new Promise(function(_0x378dbe,_0x2b0519){return db[_0xa817('0x19')][_0xa817('0x1a')]({'raw':_0x1abe0b[_0xa817('0x1b')]?_0x1abe0b['options']['raw']===undefined?!![]:![]:!![],'where':_0x1abe0b[_0xa817('0x1b')]?_0x1abe0b[_0xa817('0x1b')]['where']||null:null,'attributes':_0x1abe0b[_0xa817('0x1b')]?_0x1abe0b['options'][_0xa817('0x1c')]||null:null,'include':_0x1abe0b['options']?_0x1abe0b['options']['include']?_[_0xa817('0x1d')](_0x1abe0b['options'][_0xa817('0x1e')],function(_0x10188d){return{'model':db[_0x10188d[_0xa817('0x1f')]],'as':_0x10188d['as'],'attributes':_0x10188d[_0xa817('0x1c')],'include':_0x10188d['include']?_[_0xa817('0x1d')](_0x10188d[_0xa817('0x1e')],function(_0x3b0156){return{'model':db[_0x3b0156['model']],'as':_0x3b0156['as'],'attributes':_0x3b0156[_0xa817('0x1c')],'include':_0x3b0156[_0xa817('0x1e')]?_['map'](_0x3b0156['include'],function(_0x3ccc2b){return{'model':db[_0x3ccc2b['model']],'as':_0x3ccc2b['as'],'attributes':_0x3ccc2b[_0xa817('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xa817('0xe')](function(_0x5eae1d){logger['info'](_0xa817('0x18'),_0x1abe0b);logger['debug'](_0xa817('0x18'),_0x1abe0b,JSON['stringify'](_0x5eae1d));_0x378dbe(_0x5eae1d);})[_0xa817('0x17')](function(_0x35469f){logger[_0xa817('0x13')](_0xa817('0x18'),_0x35469f['message'],_0x1abe0b);_0x2b0519(_0x5bb9fa['error'](0x1f4,_0x35469f[_0xa817('0x15')]));});});};