Skip to content

Commit 0d92cd9

Browse files
committed
feat: get _id of invitee
1 parent a64cde0 commit 0d92cd9

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/server.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class CoCreateUser {
158158
async inviteUser(data) {
159159
try {
160160
const inviteId = this.crud.ObjectId().toString()
161+
let socket = data.socket
162+
delete data.socket
161163
let uid = data.uid
162164
delete data.uid
163165

@@ -167,6 +169,21 @@ class CoCreateUser {
167169

168170
data = await this.crud.send(data)
169171

172+
let invitee = await this.crud.send({
173+
method: 'object.read',
174+
array: 'users',
175+
$filter: {
176+
query: { email: data.email },
177+
limit: 1
178+
},
179+
organization_id: data.organization_id
180+
})
181+
182+
if (invitee.object[0]) {
183+
invitee = invitee.object[0]._id
184+
} else
185+
invitee = ''
186+
170187
let htmlBody = `
171188
<html>
172189
<head>
@@ -177,12 +194,12 @@ class CoCreateUser {
177194
178195
<p>You have been invited to join ${data.name} on Yellow Oracle.</p>
179196
180-
<p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${data.user_id}&name=${data.name}" style="color: #ffffff; background-color: #FFD700; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Accept Your Invitation</a></p>
197+
<p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${invitee}&name=${data.name}" style="color: #ffffff; background-color: #FFD700; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Accept Your Invitation</a></p>
181198
182199
<p>Please note, this invitation link will expire in 48 hours. We encourage you to accept it soon to begin your journey with ${data.name} on Yellow Oracle.</p>
183200
184201
<p>If the button above doesn't work, you can copy and paste the following URL into your web browser:</p>
185-
<p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${data.user_id}&name=${data.name}">${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${data.user_id}&name=${data.name}</a></p>
202+
<p><a href="${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${invitee}&name=${data.name}">${data.origin}${data.path}?email=${data.email}&token=${inviteId}&user_id=${invitee}&name=${data.name}</a></p>
186203
187204
<p>If you received this invitation by mistake or have any questions, please don't hesitate to get in touch with our support team at <a href="mailto:support@${data.hostname}">support@${data.hostname}</a>.</p>
188205
@@ -210,7 +227,7 @@ class CoCreateUser {
210227
this.wsManager.emit('postmark', email);
211228

212229
let response = {
213-
socket: data.socket,
230+
socket,
214231
host: data.host,
215232
method: 'inviteUser',
216233
success: true,

0 commit comments

Comments
 (0)