0e11c8318ac6550af8868f1dffe3fad741473c99
[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 _0x3ecc=['find','options','raw','attributes','include','map','model','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','register','request','then','info','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappAccount,\x20%s,\x20%s','message','catch','ShowWhatsappAccount'];(function(_0x53ddab,_0x4ada9d){var _0x5819ac=function(_0x4d5fc8){while(--_0x4d5fc8){_0x53ddab['push'](_0x53ddab['shift']());}};_0x5819ac(++_0x4ada9d);}(_0x3ecc,0x12f));var _0xc3ec=function(_0x1bd29e,_0x17f961){_0x1bd29e=_0x1bd29e-0x0;var _0x1e1a66=_0x3ecc[_0x1bd29e];return _0x1e1a66;};'use strict';var _=require('lodash');var util=require(_0xc3ec('0x0'));var moment=require(_0xc3ec('0x1'));var BPromise=require('bluebird');var rs=require(_0xc3ec('0x2'));var fs=require('fs');var Redis=require(_0xc3ec('0x3'));var db=require(_0xc3ec('0x4'))['db'];var utils=require(_0xc3ec('0x5'));var logger=require(_0xc3ec('0x6'))(_0xc3ec('0x7'));var config=require(_0xc3ec('0x8'));var jayson=require(_0xc3ec('0x9'));var client=jayson['client'][_0xc3ec('0xa')]({'port':0x232a});config[_0xc3ec('0xb')]=_[_0xc3ec('0xc')](config[_0xc3ec('0xb')],{'host':_0xc3ec('0xd'),'port':0x18eb});var socket=require(_0xc3ec('0xe'))(new Redis(config['redis']));require(_0xc3ec('0xf'))[_0xc3ec('0x10')](socket);function respondWithRpcPromise(_0x59d44a,_0x32a36a,_0x5209b1){return new BPromise(function(_0x55a144,_0x54f0a2){return client[_0xc3ec('0x11')](_0x59d44a,_0x5209b1)[_0xc3ec('0x12')](function(_0x38f434){logger[_0xc3ec('0x13')]('WhatsappAccount,\x20%s,\x20%s',_0x32a36a,_0xc3ec('0x14'));logger[_0xc3ec('0x15')](_0xc3ec('0x16'),_0x32a36a,'request\x20sent',JSON[_0xc3ec('0x17')](_0x38f434));if(_0x38f434['error']){if(_0x38f434[_0xc3ec('0x18')][_0xc3ec('0x19')]===0x1f4){logger[_0xc3ec('0x18')](_0xc3ec('0x1a'),_0x32a36a,_0x38f434[_0xc3ec('0x18')][_0xc3ec('0x1b')]);return _0x54f0a2(_0x38f434[_0xc3ec('0x18')][_0xc3ec('0x1b')]);}logger[_0xc3ec('0x18')](_0xc3ec('0x1a'),_0x32a36a,_0x38f434[_0xc3ec('0x18')][_0xc3ec('0x1b')]);return _0x55a144(_0x38f434[_0xc3ec('0x18')][_0xc3ec('0x1b')]);}else{logger[_0xc3ec('0x13')](_0xc3ec('0x1a'),_0x32a36a,'request\x20sent');_0x55a144(_0x38f434['result'][_0xc3ec('0x1b')]);}})[_0xc3ec('0x1c')](function(_0x20eefa){logger[_0xc3ec('0x18')](_0xc3ec('0x1a'),_0x32a36a,_0x20eefa);_0x54f0a2(_0x20eefa);});});}exports[_0xc3ec('0x1d')]=function(_0x152dc3){var _0x3907df=this;return new Promise(function(_0x5bb428,_0x4867b8){return db['WhatsappAccount'][_0xc3ec('0x1e')]({'raw':_0x152dc3['options']?_0x152dc3[_0xc3ec('0x1f')][_0xc3ec('0x20')]===undefined?!![]:![]:!![],'where':_0x152dc3[_0xc3ec('0x1f')]?_0x152dc3['options']['where']||null:null,'attributes':_0x152dc3[_0xc3ec('0x1f')]?_0x152dc3['options'][_0xc3ec('0x21')]||null:null,'include':_0x152dc3[_0xc3ec('0x1f')]?_0x152dc3[_0xc3ec('0x1f')][_0xc3ec('0x22')]?_[_0xc3ec('0x23')](_0x152dc3[_0xc3ec('0x1f')][_0xc3ec('0x22')],function(_0xc93a2b){return{'model':db[_0xc93a2b[_0xc3ec('0x24')]],'as':_0xc93a2b['as'],'attributes':_0xc93a2b[_0xc3ec('0x21')],'include':_0xc93a2b['include']?_[_0xc3ec('0x23')](_0xc93a2b[_0xc3ec('0x22')],function(_0x175851){return{'model':db[_0x175851['model']],'as':_0x175851['as'],'attributes':_0x175851['attributes'],'include':_0x175851['include']?_[_0xc3ec('0x23')](_0x175851[_0xc3ec('0x22')],function(_0x20e750){return{'model':db[_0x20e750[_0xc3ec('0x24')]],'as':_0x20e750['as'],'attributes':_0x20e750['attributes']};}):[]};}):[]};}):[]:[]})[_0xc3ec('0x12')](function(_0x44d2c9){logger[_0xc3ec('0x13')]('ShowWhatsappAccount',_0x152dc3);logger[_0xc3ec('0x15')](_0xc3ec('0x1d'),_0x152dc3,JSON['stringify'](_0x44d2c9));_0x5bb428(_0x44d2c9);})['catch'](function(_0x2e3370){logger[_0xc3ec('0x18')](_0xc3ec('0x1d'),_0x2e3370['message'],_0x152dc3);_0x4867b8(_0x3907df[_0xc3ec('0x18')](0x1f4,_0x2e3370[_0xc3ec('0x1b')]));});});};