diff --git a/backend/events-listener/controllers/notifications.js b/backend/events-listener/controllers/notifications.js index 72841cf7..0d6399af 100644 --- a/backend/events-listener/controllers/notifications.js +++ b/backend/events-listener/controllers/notifications.js @@ -4,11 +4,12 @@ import admin from "firebase-admin"; async function processReceivedMessage() { try{ - const queueName = 'notifications'; + const queueName = 'events-queue'; const receivedMsg = await receiveMessageFromQueue(queueName); if(receivedMsg !== null){ console.log("Received message:", receivedMsg); - handleNotification(receivedMsg); + // handleNotification(receivedMsg); + }else { console.log("No messages received..."); } diff --git a/backend/events-listener/server.js b/backend/events-listener/server.js index 20a73413..626680c0 100644 --- a/backend/events-listener/server.js +++ b/backend/events-listener/server.js @@ -15,5 +15,5 @@ const PORT = 8006; // initialize body-parser middleware app.use(bodyParser.json()); // will be using Json data app.use('/notifications', notify); -app.get('/', (req, res) => res.send(" Notifications services")); +app.get('/', (req, res) => res.send(" Events listener service")); app.listen(PORT, () => console.log(`Server running on port: http://localhost:${PORT}`)); \ No newline at end of file diff --git a/backend/gateway-service/routes.json b/backend/gateway-service/routes.json index d035f4df..64eda02d 100644 --- a/backend/gateway-service/routes.json +++ b/backend/gateway-service/routes.json @@ -1,8 +1,8 @@ { "/c": "https://event-chats-service-wcjsbin3oq-uc.a.run.app", "/p": "https://event-posts-service-old-wcjsbin3oq-uc.a.run.app", - "/e": "http://localhost:8004", - "/u": "https://user-management-service-wcjsbin3oq-uc.a.run.app", + "/e": "https://events-service-wcjsbin3oq-uc.a.run.app", + "/u": "http://localhost:8002", "/n": "https://notifications-service-wcjsbin3oq-uc.a.run.app", - "/posts": "https://xpose-posts-service-wcjsbin3oq-uc.a.run.app" + "/posts": "http://127.0.0.1:5000" } \ No newline at end of file diff --git a/backend/user-management-service/controllers/deleteUser.js b/backend/user-management-service/controllers/deleteUser.js index 1348b6dd..afb185d7 100644 --- a/backend/user-management-service/controllers/deleteUser.js +++ b/backend/user-management-service/controllers/deleteUser.js @@ -3,6 +3,8 @@ import admin from "firebase-admin"; import User from '../data-access/models/user.table.js'; import Friendship from '../data-access/models/friendship.table.js'; import { Op } from 'sequelize'; +import { sendMessageToQueue } from '../sender.js'; +import MessageBuilder from './messagebuilder.js'; let users = []; export const deleteUser = async (req, res) => { @@ -32,6 +34,18 @@ export const deleteUser = async (req, res) => { } }); + + // send delete user message to rabbitmq + // const queueName = 'notifications'; + console.log('Sending delete user message to rabbitmq'); + const message = new MessageBuilder().setType("delete_user").setValue({deleted_user_id: userId}).build(); + console.log('Message: ', message); + + sendMessageToQueue('posts-queue', message); + sendMessageToQueue('events-queue', message); + + console.log(`Messages sent to rabbitmq`); + res.status(200).json({message:`User with the id ${userId} deleted from DB successfuly`}); } catch(error) {