Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / whatsappAccount / whatsappAccount.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 _0x96bd=['socket.io-emitter','./whatsappAccount.socket','request','then','info','WhatsappAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','ShowWhatsappAccount','options','raw','where','attributes','map','model','include','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost'];(function(_0x30abff,_0x5f2c5f){var _0x4c571e=function(_0x43de9a){while(--_0x43de9a){_0x30abff['push'](_0x30abff['shift']());}};_0x4c571e(++_0x5f2c5f);}(_0x96bd,0x112));var _0xd96b=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x96bd[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0xd96b('0x0'));var util=require('util');var moment=require(_0xd96b('0x1'));var BPromise=require(_0xd96b('0x2'));var rs=require(_0xd96b('0x3'));var fs=require('fs');var Redis=require(_0xd96b('0x4'));var db=require(_0xd96b('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xd96b('0x6'))('rpc');var config=require(_0xd96b('0x7'));var jayson=require(_0xd96b('0x8'));var client=jayson[_0xd96b('0x9')][_0xd96b('0xa')]({'port':0x232a});config[_0xd96b('0xb')]=_[_0xd96b('0xc')](config[_0xd96b('0xb')],{'host':_0xd96b('0xd'),'port':0x18eb});var socket=require(_0xd96b('0xe'))(new Redis(config[_0xd96b('0xb')]));require(_0xd96b('0xf'))['register'](socket);function respondWithRpcPromise(_0x5d558b,_0x765734,_0x3b2790){return new BPromise(function(_0x5db303,_0x5b461d){return client[_0xd96b('0x10')](_0x5d558b,_0x3b2790)[_0xd96b('0x11')](function(_0x16a7ee){logger[_0xd96b('0x12')](_0xd96b('0x13'),_0x765734,'request\x20sent');logger[_0xd96b('0x14')]('WhatsappAccount,\x20%s,\x20%s,\x20%s',_0x765734,_0xd96b('0x15'),JSON[_0xd96b('0x16')](_0x16a7ee));if(_0x16a7ee[_0xd96b('0x17')]){if(_0x16a7ee[_0xd96b('0x17')][_0xd96b('0x18')]===0x1f4){logger[_0xd96b('0x17')](_0xd96b('0x13'),_0x765734,_0x16a7ee[_0xd96b('0x17')]['message']);return _0x5b461d(_0x16a7ee[_0xd96b('0x17')]['message']);}logger[_0xd96b('0x17')](_0xd96b('0x13'),_0x765734,_0x16a7ee[_0xd96b('0x17')][_0xd96b('0x19')]);return _0x5db303(_0x16a7ee[_0xd96b('0x17')][_0xd96b('0x19')]);}else{logger[_0xd96b('0x12')]('WhatsappAccount,\x20%s,\x20%s',_0x765734,_0xd96b('0x15'));_0x5db303(_0x16a7ee[_0xd96b('0x1a')][_0xd96b('0x19')]);}})[_0xd96b('0x1b')](function(_0x5b182b){logger[_0xd96b('0x17')](_0xd96b('0x13'),_0x765734,_0x5b182b);_0x5b461d(_0x5b182b);});});}exports[_0xd96b('0x1c')]=function(_0x23bbef){var _0x5dd184=this;return new Promise(function(_0x476872,_0x4262f5){return db['WhatsappAccount']['find']({'raw':_0x23bbef[_0xd96b('0x1d')]?_0x23bbef[_0xd96b('0x1d')][_0xd96b('0x1e')]===undefined?!![]:![]:!![],'where':_0x23bbef['options']?_0x23bbef[_0xd96b('0x1d')][_0xd96b('0x1f')]||null:null,'attributes':_0x23bbef[_0xd96b('0x1d')]?_0x23bbef[_0xd96b('0x1d')][_0xd96b('0x20')]||null:null,'include':_0x23bbef[_0xd96b('0x1d')]?_0x23bbef[_0xd96b('0x1d')]['include']?_[_0xd96b('0x21')](_0x23bbef[_0xd96b('0x1d')]['include'],function(_0x35a921){return{'model':db[_0x35a921[_0xd96b('0x22')]],'as':_0x35a921['as'],'attributes':_0x35a921[_0xd96b('0x20')],'include':_0x35a921[_0xd96b('0x23')]?_[_0xd96b('0x21')](_0x35a921[_0xd96b('0x23')],function(_0x5bfbd7){return{'model':db[_0x5bfbd7[_0xd96b('0x22')]],'as':_0x5bfbd7['as'],'attributes':_0x5bfbd7[_0xd96b('0x20')],'include':_0x5bfbd7[_0xd96b('0x23')]?_[_0xd96b('0x21')](_0x5bfbd7[_0xd96b('0x23')],function(_0xf481fd){return{'model':db[_0xf481fd[_0xd96b('0x22')]],'as':_0xf481fd['as'],'attributes':_0xf481fd[_0xd96b('0x20')]};}):[]};}):[]};}):[]:[]})[_0xd96b('0x11')](function(_0x5c67dc){logger[_0xd96b('0x12')]('ShowWhatsappAccount',_0x23bbef);logger[_0xd96b('0x14')](_0xd96b('0x1c'),_0x23bbef,JSON[_0xd96b('0x16')](_0x5c67dc));_0x476872(_0x5c67dc);})[_0xd96b('0x1b')](function(_0x5189ae){logger[_0xd96b('0x17')](_0xd96b('0x1c'),_0x5189ae['message'],_0x23bbef);_0x4262f5(_0x5dd184[_0xd96b('0x17')](0x1f4,_0x5189ae[_0xd96b('0x19')]));});});};