Built motion from commit bbec7235.|2.6.20
[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 _0xbc4b=['code','WhatsappAccount,\x20%s,\x20%s','message','info','result','catch','ShowWhatsappAccount','WhatsappAccount','find','options','raw','where','include','model','map','attributes','then','debug','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','register','request','request\x20sent','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x18abd2,_0x22d4b3){var _0x1dcad6=function(_0xcc08c4){while(--_0xcc08c4){_0x18abd2['push'](_0x18abd2['shift']());}};_0x1dcad6(++_0x22d4b3);}(_0xbc4b,0x1a2));var _0xbbc4=function(_0x21b695,_0x4fcaa6){_0x21b695=_0x21b695-0x0;var _0x51324f=_0xbc4b[_0x21b695];return _0x51324f;};'use strict';var _=require(_0xbbc4('0x0'));var util=require(_0xbbc4('0x1'));var moment=require(_0xbbc4('0x2'));var BPromise=require('bluebird');var rs=require(_0xbbc4('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbbc4('0x4'))['db'];var utils=require(_0xbbc4('0x5'));var logger=require(_0xbbc4('0x6'))(_0xbbc4('0x7'));var config=require(_0xbbc4('0x8'));var jayson=require(_0xbbc4('0x9'));var client=jayson['client'][_0xbbc4('0xa')]({'port':0x232a});config[_0xbbc4('0xb')]=_[_0xbbc4('0xc')](config['redis'],{'host':_0xbbc4('0xd'),'port':0x18eb});var socket=require(_0xbbc4('0xe'))(new Redis(config[_0xbbc4('0xb')]));require(_0xbbc4('0xf'))[_0xbbc4('0x10')](socket);function respondWithRpcPromise(_0x9a8904,_0xf82780,_0x2decb4){return new BPromise(function(_0x5d3a52,_0x1aab31){return client[_0xbbc4('0x11')](_0x9a8904,_0x2decb4)['then'](function(_0x418ae6){logger['info']('WhatsappAccount,\x20%s,\x20%s',_0xf82780,_0xbbc4('0x12'));logger['debug'](_0xbbc4('0x13'),_0xf82780,_0xbbc4('0x12'),JSON[_0xbbc4('0x14')](_0x418ae6));if(_0x418ae6[_0xbbc4('0x15')]){if(_0x418ae6['error'][_0xbbc4('0x16')]===0x1f4){logger[_0xbbc4('0x15')](_0xbbc4('0x17'),_0xf82780,_0x418ae6[_0xbbc4('0x15')][_0xbbc4('0x18')]);return _0x1aab31(_0x418ae6[_0xbbc4('0x15')][_0xbbc4('0x18')]);}logger['error'](_0xbbc4('0x17'),_0xf82780,_0x418ae6['error'][_0xbbc4('0x18')]);return _0x5d3a52(_0x418ae6['error'][_0xbbc4('0x18')]);}else{logger[_0xbbc4('0x19')](_0xbbc4('0x17'),_0xf82780,'request\x20sent');_0x5d3a52(_0x418ae6[_0xbbc4('0x1a')]['message']);}})[_0xbbc4('0x1b')](function(_0x42ce3d){logger['error'](_0xbbc4('0x17'),_0xf82780,_0x42ce3d);_0x1aab31(_0x42ce3d);});});}exports[_0xbbc4('0x1c')]=function(_0x5637ec){var _0x5d0958=this;return new Promise(function(_0x398279,_0x10b184){return db[_0xbbc4('0x1d')][_0xbbc4('0x1e')]({'raw':_0x5637ec[_0xbbc4('0x1f')]?_0x5637ec['options'][_0xbbc4('0x20')]===undefined?!![]:![]:!![],'where':_0x5637ec['options']?_0x5637ec[_0xbbc4('0x1f')][_0xbbc4('0x21')]||null:null,'attributes':_0x5637ec[_0xbbc4('0x1f')]?_0x5637ec[_0xbbc4('0x1f')]['attributes']||null:null,'include':_0x5637ec[_0xbbc4('0x1f')]?_0x5637ec[_0xbbc4('0x1f')]['include']?_['map'](_0x5637ec[_0xbbc4('0x1f')][_0xbbc4('0x22')],function(_0x3280ab){return{'model':db[_0x3280ab[_0xbbc4('0x23')]],'as':_0x3280ab['as'],'attributes':_0x3280ab['attributes'],'include':_0x3280ab[_0xbbc4('0x22')]?_[_0xbbc4('0x24')](_0x3280ab[_0xbbc4('0x22')],function(_0x27d4d6){return{'model':db[_0x27d4d6[_0xbbc4('0x23')]],'as':_0x27d4d6['as'],'attributes':_0x27d4d6[_0xbbc4('0x25')],'include':_0x27d4d6[_0xbbc4('0x22')]?_[_0xbbc4('0x24')](_0x27d4d6[_0xbbc4('0x22')],function(_0x1203a9){return{'model':db[_0x1203a9['model']],'as':_0x1203a9['as'],'attributes':_0x1203a9[_0xbbc4('0x25')]};}):[]};}):[]};}):[]:[]})[_0xbbc4('0x26')](function(_0x14bfac){logger[_0xbbc4('0x19')](_0xbbc4('0x1c'),_0x5637ec);logger[_0xbbc4('0x27')]('ShowWhatsappAccount',_0x5637ec,JSON['stringify'](_0x14bfac));_0x398279(_0x14bfac);})[_0xbbc4('0x1b')](function(_0x345e43){logger[_0xbbc4('0x15')](_0xbbc4('0x1c'),_0x345e43[_0xbbc4('0x18')],_0x5637ec);_0x10b184(_0x5d0958['error'](0x1f4,_0x345e43[_0xbbc4('0x18')]));});});};