Commit 0c544102 authored by Balasuriya D.A.M.'s avatar Balasuriya D.A.M.

Rename Group/Organization API

parent 8b0a4e39
......@@ -108,4 +108,28 @@ const createGroupChat = asyncHandler(async (req, res) => {
}
});
module.exports = { accessChat, fetchChats, createGroupChat };
\ No newline at end of file
const renameGroup = asyncHandler(async (req, res) => {
const { chatId, chatName } = req.body;
const updatedChat = await Chat.findByIdAndUpdate(
chatId,
{
chatName,
},
{
new: true,
}
)
.populate("users", "-password")
.populate("groupAdmin", "-password");
if (!updatedChat) {
res.status(404);
throw new Error("Organization Not Found");//chat not found
} else {
res.json(updatedChat);
}
});
module.exports = { accessChat, fetchChats, createGroupChat, renameGroup };
\ No newline at end of file
const express = require("express");
const { accessChat, fetchChats, createGroupChat } = require("../controllers/chatControllers");
const { accessChat, fetchChats, createGroupChat, renameGroup} = require("../controllers/chatControllers");
const { protect } = require("../middleware/authMiddleware");
......@@ -12,7 +12,7 @@ const router = express.Router();
router.route("/").post(protect, accessChat); //API route for one on one chat
router.route("/").get(protect, fetchChats);
router.route("/group").post(protect, createGroupChat); //create group
//router.route("/rename").put(protect, renameGroup); //update group
router.route("/rename").put(protect, renameGroup); //update group
//router.route("/groupremove").put(protect, removeFromGroup); //remove from group
//router.route("/groupadd").put(protect, addToGroup); //add someone to group
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment