Built motion from commit (unavailable).|2.5.4
[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 _0x16e8=['debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowWhatsappAccount','WhatsappAccount','options','raw','where','attributes','include','map','model','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','http','defaults','redis','localhost','register','request','then','info','WhatsappAccount,\x20%s,\x20%s','request\x20sent'];(function(_0x1ad759,_0x534529){var _0x553a8e=function(_0x16f8ec){while(--_0x16f8ec){_0x1ad759['push'](_0x1ad759['shift']());}};_0x553a8e(++_0x534529);}(_0x16e8,0x106));var _0x816e=function(_0x30b49c,_0x4dcce5){_0x30b49c=_0x30b49c-0x0;var _0x2b2f63=_0x16e8[_0x30b49c];return _0x2b2f63;};'use strict';var _=require('lodash');var util=require(_0x816e('0x0'));var moment=require(_0x816e('0x1'));var BPromise=require(_0x816e('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x816e('0x3'));var db=require(_0x816e('0x4'))['db'];var utils=require(_0x816e('0x5'));var logger=require('../../config/logger')(_0x816e('0x6'));var config=require('../../config/environment');var jayson=require(_0x816e('0x7'));var client=jayson['client'][_0x816e('0x8')]({'port':0x232a});config['redis']=_[_0x816e('0x9')](config[_0x816e('0xa')],{'host':_0x816e('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x816e('0xa')]));require('./whatsappAccount.socket')[_0x816e('0xc')](socket);function respondWithRpcPromise(_0x49a325,_0x58b814,_0x2210fe){return new BPromise(function(_0x337372,_0x3e355d){return client[_0x816e('0xd')](_0x49a325,_0x2210fe)[_0x816e('0xe')](function(_0x38e4cd){logger[_0x816e('0xf')](_0x816e('0x10'),_0x58b814,_0x816e('0x11'));logger[_0x816e('0x12')](_0x816e('0x13'),_0x58b814,_0x816e('0x11'),JSON[_0x816e('0x14')](_0x38e4cd));if(_0x38e4cd[_0x816e('0x15')]){if(_0x38e4cd[_0x816e('0x15')][_0x816e('0x16')]===0x1f4){logger[_0x816e('0x15')](_0x816e('0x10'),_0x58b814,_0x38e4cd[_0x816e('0x15')][_0x816e('0x17')]);return _0x3e355d(_0x38e4cd['error'][_0x816e('0x17')]);}logger['error'](_0x816e('0x10'),_0x58b814,_0x38e4cd[_0x816e('0x15')][_0x816e('0x17')]);return _0x337372(_0x38e4cd[_0x816e('0x15')][_0x816e('0x17')]);}else{logger[_0x816e('0xf')](_0x816e('0x10'),_0x58b814,'request\x20sent');_0x337372(_0x38e4cd[_0x816e('0x18')][_0x816e('0x17')]);}})[_0x816e('0x19')](function(_0x3d471b){logger[_0x816e('0x15')](_0x816e('0x10'),_0x58b814,_0x3d471b);_0x3e355d(_0x3d471b);});});}exports[_0x816e('0x1a')]=function(_0x5020b2){var _0x156b25=this;return new Promise(function(_0x353d0b,_0x435f49){return db[_0x816e('0x1b')]['find']({'raw':_0x5020b2[_0x816e('0x1c')]?_0x5020b2[_0x816e('0x1c')][_0x816e('0x1d')]===undefined?!![]:![]:!![],'where':_0x5020b2['options']?_0x5020b2[_0x816e('0x1c')][_0x816e('0x1e')]||null:null,'attributes':_0x5020b2[_0x816e('0x1c')]?_0x5020b2[_0x816e('0x1c')][_0x816e('0x1f')]||null:null,'include':_0x5020b2[_0x816e('0x1c')]?_0x5020b2[_0x816e('0x1c')][_0x816e('0x20')]?_[_0x816e('0x21')](_0x5020b2[_0x816e('0x1c')][_0x816e('0x20')],function(_0x3f9c82){return{'model':db[_0x3f9c82[_0x816e('0x22')]],'as':_0x3f9c82['as'],'attributes':_0x3f9c82[_0x816e('0x1f')],'include':_0x3f9c82[_0x816e('0x20')]?_[_0x816e('0x21')](_0x3f9c82[_0x816e('0x20')],function(_0xd57ebf){return{'model':db[_0xd57ebf[_0x816e('0x22')]],'as':_0xd57ebf['as'],'attributes':_0xd57ebf[_0x816e('0x1f')],'include':_0xd57ebf[_0x816e('0x20')]?_[_0x816e('0x21')](_0xd57ebf[_0x816e('0x20')],function(_0x2ad4b4){return{'model':db[_0x2ad4b4['model']],'as':_0x2ad4b4['as'],'attributes':_0x2ad4b4[_0x816e('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x816e('0xe')](function(_0x23c280){logger[_0x816e('0xf')](_0x816e('0x1a'),_0x5020b2);logger[_0x816e('0x12')](_0x816e('0x1a'),_0x5020b2,JSON[_0x816e('0x14')](_0x23c280));_0x353d0b(_0x23c280);})['catch'](function(_0x1fc66e){logger['error'](_0x816e('0x1a'),_0x1fc66e[_0x816e('0x17')],_0x5020b2);_0x435f49(_0x156b25[_0x816e('0x15')](0x1f4,_0x1fc66e[_0x816e('0x17')]));});});};