adding in check route for one on one

This commit is contained in:
talksik
2022-06-11 10:40:10 -05:00
parent f2f5148d35
commit 701ae1fdde
2 changed files with 49 additions and 1 deletions
@@ -28,4 +28,27 @@ export default class ConversationService {
return undefined;
}
/**
* gets one on one conversation between two people if it exists
*/
static async getConversationBetweenTwoPeople(userAId: ObjectId, userBId: ObjectId) {
const query = {
$and: [
{
'members._id': userAId,
},
{ 'members._id': userBId },
],
};
const res = await collections.conversations?.findOne(query);
// exists
if (res?._id) {
return res as Conversation;
}
return null;
}
}