nice checking if exists or not

This commit is contained in:
talksik
2022-06-11 11:15:39 -05:00
parent 609059b78d
commit 4527d110d7
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -74,7 +74,9 @@ const getOneOnOneConversationIfExists = async (req: Request, res: Response, next
new NirvanaResponse(
resultConversation?._id ?? undefined,
undefined,
'here is the conversation if it exists',
resultConversation
? 'no such conversation exists!'
: 'there is a conversation...quick dial them now!',
),
);
} catch (error) {
@@ -93,6 +95,18 @@ const createConversation = async (req: Request, res: Response, next: NextFunctio
return next(new Error('must provide who you want to talk to'));
}
// if it's a one on one, and one already exists then don't allow creating another convo!!
if (createRequest.otherUsers.length === 1) {
const oneOnOneExists = await ConversationService.getConversationBetweenTwoPeople(
new ObjectId(userInfo.userId),
new ObjectId(createRequest.otherUsers[0]._id),
);
if (oneOnOneExists) {
return next(Error('Already have a conversatoin with them! quick dial them!'));
}
}
// process of creating other conversation user members with their user objects
// for cached data purposes
const conversationUserMembers: ConversationUserMember[] = [];
+1
View File
@@ -61,6 +61,7 @@ export default function Login() {
alignItems: 'center',
gap: 5,
background: blueGrey[50],
WebkitAppRegion: 'drag',
}}
>
<NirvanaLogo />