diff --git a/server/shell.ts b/server/shell.ts index 0782ed9..4724979 100644 --- a/server/shell.ts +++ b/server/shell.ts @@ -413,12 +413,15 @@ export function renderShell(opts: ShellOptions): string { if (!raw) return; var session = JSON.parse(raw); if (!session || !session.accessToken) return; - fetch('/' + '${escapeAttr(spaceSlug)}' + '/invite/accept', { + fetch('/api/spaces/' + encodeURIComponent('${escapeAttr(spaceSlug)}') + '/invite/accept', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + session.accessToken }, body: JSON.stringify({ inviteToken: inviteToken }), }).then(function(res) { return res.json(); }).then(function(data) { - if (data.ok) { window.location.reload(); } + if (data.ok) { + var slug = data.spaceSlug || '${escapeAttr(spaceSlug)}'; + window.location.href = 'https://' + slug + '.rspace.online'; + } }); } catch(e) {} } diff --git a/server/spaces.ts b/server/spaces.ts index 583abee..0ff8556 100644 --- a/server/spaces.ts +++ b/server/spaces.ts @@ -2194,7 +2194,7 @@ spaces.post("/:slug/invite", async (c) => { spaceSlug: slug, actorDid: claims.sub, actorUsername: claims.username, - actionUrl: `/rspace`, + actionUrl: `https://${slug}.rspace.online`, metadata: { role }, }).catch(() => {}); @@ -2209,15 +2209,21 @@ spaces.post("/:slug/invite", async (c) => { if (inviteTransport) { try { const spaceUrl = `https://${slug}.rspace.online`; + const inviterName = claims.username || "an admin"; await inviteTransport.sendMail({ from: process.env.SMTP_FROM || "rSpace ", to: body.email, - subject: `You've been added to "${slug}" on rSpace`, - html: [ - `

You've been added to ${slug} as a ${role}.

`, - `

Open Space

`, - `

rSpace — collaborative knowledge work

`, - ].join("\n"), + subject: `${inviterName} added you to "${slug}" on rSpace`, + html: ` +
+

You've been added to ${slug}

+

${inviterName} added you to the ${slug} space as a ${role}.

+

You now have access to all the collaborative tools in this space — notes, maps, voting, calendar, and more.

+

+ Open ${slug} +

+

rSpace — collaborative knowledge work

+
`, }); } catch (emailErr: any) { console.error("Direct-add email notification failed:", emailErr.message); @@ -2309,7 +2315,7 @@ spaces.post("/:slug/members/add", async (c) => { spaceSlug: slug, actorDid: claims.sub, actorUsername: claims.username, - actionUrl: `/rspace`, + actionUrl: `https://${slug}.rspace.online`, metadata: { role }, }).catch(() => {}); diff --git a/src/encryptid/server.ts b/src/encryptid/server.ts index b7b2da4..b5bab16 100644 --- a/src/encryptid/server.ts +++ b/src/encryptid/server.ts @@ -5407,22 +5407,28 @@ app.post('/api/invites/identity', async (c) => { const joinLink = `https://auth.rspace.online/join?token=${encodeURIComponent(token)}`; if (smtpTransport) { try { + const spaceInfo = spaceSlug + ? `

You'll automatically join the ${escapeHtml(spaceSlug)} space as a ${escapeHtml(spaceRole || 'member')}, with access to collaborative notes, maps, voting, calendar, and more.

` + : `

rSpace is a suite of privacy-first collaborative tools — notes, maps, voting, calendar, wallet, and more — powered by passkey authentication (no passwords).

`; + const subjectLine = spaceSlug + ? `${payload.username} invited you to join "${spaceSlug}" on rSpace` + : `${payload.username} invited you to join rSpace`; await smtpTransport.sendMail({ from: CONFIG.smtp.from, to: email, - subject: `${payload.username} invited you to join rSpace`, + subject: subjectLine, html: ` -
-

You've been invited to rSpace

-

${escapeHtml(payload.username)} wants you to join the rSpace ecosystem — a suite of privacy-first tools powered by passkey authentication.

- ${message ? `
"${escapeHtml(message)}"
` : ''} -

Click below to claim your identity and set up your passkey:

-

- Claim your rSpace -

-

This invite expires in 7 days. If you didn't expect this, you can safely ignore it.

-
- `, +
+

${spaceSlug ? `You've been invited to ${escapeHtml(spaceSlug)}` : `You've been invited to rSpace`}

+

${escapeHtml(payload.username)} wants you to join${spaceSlug ? ` the ${escapeHtml(spaceSlug)} space on` : ''} rSpace.

+ ${message ? `
"${escapeHtml(message)}"
` : ''} + ${spaceInfo} +

Click below to create your account and set up your passkey:

+

+ Accept Invitation +

+

This invite expires in 7 days. No passwords needed — you'll use a passkey to sign in securely.

+
`, }); } catch (err) { console.error('EncryptID: Failed to send invite email:', (err as Error).message);