accepting request working

This commit is contained in:
talksik
2022-03-20 17:17:01 -04:00
parent cb52664020
commit 9e5b3b332a
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ async function updateRelationshipState(req: Request, res: Response) {
requestObj.newState
);
updateResult?.acknowledged
updateResult?.modifiedCount
? res.status(200).send("Updated state of relationship")
: res.status(500).send("Failed to update relationship");
+8 -4
View File
@@ -20,8 +20,8 @@ export class ContactService {
// i could also be the receiver and them the sender
const clauseTwo = {
$and: [
{ senderUserId: myGoogleUserId },
{ receiverUserId: otherGoogleUserId },
{ senderUserId: otherGoogleUserId },
{ receiverUserId: myGoogleUserId },
],
};
@@ -58,8 +58,12 @@ export class ContactService {
relationshipId: ObjectId,
newState: RelationshipState
) {
const query = { _id: relationshipId };
const updateDoc = { $set: { state: newState } };
const query = { _id: new ObjectId(relationshipId) };
console.log(newState);
console.log(relationshipId);
const updateDoc = {
$set: { state: newState, lastUpdatedDate: new Date() },
};
const result = await collections.relationships?.updateOne(query, updateDoc);
return result;