Skip to content

Commit

Permalink
group details edit added
Browse files Browse the repository at this point in the history
  • Loading branch information
farooqpk committed May 13, 2024
1 parent c78c7d2 commit f53e35b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions src/socket/socketHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,58 @@ export const socketHandler = (
}
io.to(usersSocket).emit("groupCreated");
});

socket.on(
"updateGroupDetails",
async ({
groupId,
name,
description,
}: {
groupId: string;
name?: string;
description?: string;
}) => {
const group = await prisma.group.update({
where: {
groupId,
adminId: decodedPayload.userId,
},
data: {
name,
description,
},
select: {
groupId: true,
name: true,
description: true,
Chat: {
select: {
participants: {
select: {
userId: true,
},
},
},
},
},
});

const groupMembers = group?.Chat.participants;

// clear the caches
await clearCacheFromRedis({
key: groupMembers?.map((item) => `chats:${item.userId}`),
});
await clearCacheFromRedis({
key: groupMembers?.map((item) => `group:${groupId}:${item.userId}`),
});

io.to(groupId).emit("updateGroupDetails", {
groupId,
name: group.name,
description: group.description,
});
}
);
};
2 changes: 1 addition & 1 deletion src/utils/configureExpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function configureExpress(app: express.Express) {
app.use(
rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100,
max: 150,
standardHeaders: true,
legacyHeaders: false,
})
Expand Down

0 comments on commit f53e35b

Please sign in to comment.