Built motion from commit 10af8726.|2.6.34
[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 _0x5b6e=['WhatsappAccount','find','options','raw','include','map','model','attributes','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','register','request','then','info','WhatsappAccount,\x20%s,\x20%s','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','ShowWhatsappAccount'];(function(_0x411add,_0x1aed38){var _0x238242=function(_0x4a1cd5){while(--_0x4a1cd5){_0x411add['push'](_0x411add['shift']());}};_0x238242(++_0x1aed38);}(_0x5b6e,0x14c));var _0xe5b6=function(_0x297cf8,_0x50e415){_0x297cf8=_0x297cf8-0x0;var _0x3de890=_0x5b6e[_0x297cf8];return _0x3de890;};'use strict';var _=require(_0xe5b6('0x0'));var util=require(_0xe5b6('0x1'));var moment=require('moment');var BPromise=require(_0xe5b6('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe5b6('0x3'));var db=require(_0xe5b6('0x4'))['db'];var utils=require(_0xe5b6('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xe5b6('0x6'));var jayson=require(_0xe5b6('0x7'));var client=jayson[_0xe5b6('0x8')][_0xe5b6('0x9')]({'port':0x232a});config['redis']=_[_0xe5b6('0xa')](config[_0xe5b6('0xb')],{'host':_0xe5b6('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xe5b6('0xb')]));require('./whatsappAccount.socket')[_0xe5b6('0xd')](socket);function respondWithRpcPromise(_0x46f384,_0x4faece,_0x2278eb){return new BPromise(function(_0x2b4b08,_0x5b8371){return client[_0xe5b6('0xe')](_0x46f384,_0x2278eb)[_0xe5b6('0xf')](function(_0x58ca4b){logger[_0xe5b6('0x10')](_0xe5b6('0x11'),_0x4faece,'request\x20sent');logger[_0xe5b6('0x12')](_0xe5b6('0x13'),_0x4faece,_0xe5b6('0x14'),JSON[_0xe5b6('0x15')](_0x58ca4b));if(_0x58ca4b[_0xe5b6('0x16')]){if(_0x58ca4b['error'][_0xe5b6('0x17')]===0x1f4){logger[_0xe5b6('0x16')](_0xe5b6('0x11'),_0x4faece,_0x58ca4b[_0xe5b6('0x16')][_0xe5b6('0x18')]);return _0x5b8371(_0x58ca4b[_0xe5b6('0x16')][_0xe5b6('0x18')]);}logger[_0xe5b6('0x16')](_0xe5b6('0x11'),_0x4faece,_0x58ca4b[_0xe5b6('0x16')][_0xe5b6('0x18')]);return _0x2b4b08(_0x58ca4b['error'][_0xe5b6('0x18')]);}else{logger['info'](_0xe5b6('0x11'),_0x4faece,_0xe5b6('0x14'));_0x2b4b08(_0x58ca4b[_0xe5b6('0x19')]['message']);}})[_0xe5b6('0x1a')](function(_0x64de88){logger[_0xe5b6('0x16')](_0xe5b6('0x11'),_0x4faece,_0x64de88);_0x5b8371(_0x64de88);});});}exports[_0xe5b6('0x1b')]=function(_0x195160){var _0x41afb1=this;return new Promise(function(_0x33d7d3,_0x5a88bb){return db[_0xe5b6('0x1c')][_0xe5b6('0x1d')]({'raw':_0x195160[_0xe5b6('0x1e')]?_0x195160[_0xe5b6('0x1e')][_0xe5b6('0x1f')]===undefined?!![]:![]:!![],'where':_0x195160['options']?_0x195160[_0xe5b6('0x1e')]['where']||null:null,'attributes':_0x195160[_0xe5b6('0x1e')]?_0x195160['options']['attributes']||null:null,'include':_0x195160['options']?_0x195160['options'][_0xe5b6('0x20')]?_[_0xe5b6('0x21')](_0x195160['options'][_0xe5b6('0x20')],function(_0x23bff6){return{'model':db[_0x23bff6[_0xe5b6('0x22')]],'as':_0x23bff6['as'],'attributes':_0x23bff6['attributes'],'include':_0x23bff6[_0xe5b6('0x20')]?_['map'](_0x23bff6[_0xe5b6('0x20')],function(_0x42e094){return{'model':db[_0x42e094[_0xe5b6('0x22')]],'as':_0x42e094['as'],'attributes':_0x42e094[_0xe5b6('0x23')],'include':_0x42e094[_0xe5b6('0x20')]?_[_0xe5b6('0x21')](_0x42e094[_0xe5b6('0x20')],function(_0x4348c8){return{'model':db[_0x4348c8[_0xe5b6('0x22')]],'as':_0x4348c8['as'],'attributes':_0x4348c8[_0xe5b6('0x23')]};}):[]};}):[]};}):[]:[]})[_0xe5b6('0xf')](function(_0x3c2773){logger[_0xe5b6('0x10')](_0xe5b6('0x1b'),_0x195160);logger[_0xe5b6('0x12')]('ShowWhatsappAccount',_0x195160,JSON[_0xe5b6('0x15')](_0x3c2773));_0x33d7d3(_0x3c2773);})[_0xe5b6('0x1a')](function(_0x2dc870){logger[_0xe5b6('0x16')](_0xe5b6('0x1b'),_0x2dc870[_0xe5b6('0x18')],_0x195160);_0x5a88bb(_0x41afb1[_0xe5b6('0x16')](0x1f4,_0x2dc870[_0xe5b6('0x18')]));});});};