From a17bc23370e6196c792d623d8873c3cb31218e58 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Fri, 12 Jun 2026 10:54:57 +0530 Subject: [PATCH] fix profile server refresh --- server/src/routes/profile.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/src/routes/profile.js b/server/src/routes/profile.js index 47e4470..595dc26 100644 --- a/server/src/routes/profile.js +++ b/server/src/routes/profile.js @@ -7,6 +7,7 @@ import bcrypt from "bcryptjs"; import { buildAuthUserJwtPayload } from "../lib/authJwtPayload.js"; import { authToken } from "../middleware/auth.js"; import User from "../models/User.js"; +import { getIO } from "../socket/runtime.js"; const router = express.Router(); @@ -154,6 +155,18 @@ router.patch("/", authToken, async (req, res) => { profile_pic: $set.profile_pic, }); + const io = getIO(); + if (io && Array.isArray(updated.servers)) { + for (const server of updated.servers) { + if (!server?.server_id) continue; + io.to(`server:${String(server.server_id)}`).emit("server_updated", { + server_id: String(server.server_id), + reason: "member_profile_updated", + user_id: String(userId), + }); + } + } + const token = jwt.sign( buildAuthUserJwtPayload(updated), config.ACCESS_TOKEN