Skip to content

Commit

Permalink
fix pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienDrozd committed Dec 23, 2023
1 parent 51a94fb commit ef85c54
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/controllers/conversation.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ exports.getAllConversation = (req, res, next) => {

exports.createConversation = (req, res, next) => {
try {
console.log("createConversation")
//création de la nouvelle conversation
const newConversation = new Conversation({
messages: [],
});

//ajout de la conversation dans la liste des conversations de l'utilisateur 1
//adding the conversation to the user's list of conversations
User.findOneAndUpdate(
{ _id: req.body.user1 },
{ $push: { matches: [newConversation] } }
).then((User1) => {

//ajout de la conversation dans la liste des conversations de l'utilisateur 2
User.findOneAndUpdate(
{
_id:
Expand All @@ -50,7 +47,7 @@ exports.createConversation = (req, res, next) => {
if (existingConversation) {
// Conversation already exists
res.send({
message: "Conversation already exists",
mes sage: "Conversation already exists",
conversationId: existingConversation._id,
});
} else {
Expand Down Expand Up @@ -124,11 +121,11 @@ exports.createInstantConversation = (req, res, next) => {
newConversation.members.push(User1);
newConversation.members.push(User2);
newConversation.save().then((conversation) => {
res.send({
message:
"conversation " + conversation._id + " successfully added", conversation: conversation,
});
})
res.send({
message:
"conversation " + conversation._id + " successfully added", conversation: conversation,
});
})
.catch((error) => {
next(error);
});
Expand All @@ -138,11 +135,12 @@ exports.createInstantConversation = (req, res, next) => {
next(error);
});
})
.catch((error) => {v
.catch((error) => {
next(error);
});
})
.catch((error) => {;
.catch((error) => {
;
next(error);
});
} else {
Expand Down

0 comments on commit ef85c54

Please sign in to comment.