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 requestObj.newState
); );
updateResult?.acknowledged updateResult?.modifiedCount
? res.status(200).send("Updated state of relationship") ? res.status(200).send("Updated state of relationship")
: res.status(500).send("Failed to update 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 // i could also be the receiver and them the sender
const clauseTwo = { const clauseTwo = {
$and: [ $and: [
{ senderUserId: myGoogleUserId }, { senderUserId: otherGoogleUserId },
{ receiverUserId: otherGoogleUserId }, { receiverUserId: myGoogleUserId },
], ],
}; };
@@ -58,8 +58,12 @@ export class ContactService {
relationshipId: ObjectId, relationshipId: ObjectId,
newState: RelationshipState newState: RelationshipState
) { ) {
const query = { _id: relationshipId }; const query = { _id: new ObjectId(relationshipId) };
const updateDoc = { $set: { state: newState } }; console.log(newState);
console.log(relationshipId);
const updateDoc = {
$set: { state: newState, lastUpdatedDate: new Date() },
};
const result = await collections.relationships?.updateOne(query, updateDoc); const result = await collections.relationships?.updateOne(query, updateDoc);
return result; return result;