|
|
@ -159,10 +159,15 @@ export default class ChatService extends SiteService { |
|
|
|
{ email: inviteDefinition.usernameOrEmail }, |
|
|
|
], |
|
|
|
}).lean(); |
|
|
|
if (invitee) { |
|
|
|
|
|
|
|
const existingInvite = await ChatRoomInvite |
|
|
|
.find({ room: room._id, member: invitee._id }) |
|
|
|
.select('_id') |
|
|
|
.lean(); |
|
|
|
if (existingInvite) { |
|
|
|
throw new SiteError(400, 'User already invited to room'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const invite = new ChatRoomInvite(); |
|
|
|
invite.created = NOW; |
|
|
|
invite.token = uuidv4(); |
|
|
|