6 Commits
Author SHA1 Message Date
MichelleandClaude Fable 5 6a312ba055 chore: update version to 2.5.0
Build & Push Docker Image / build (release) Successful in 3m56s
Build & Push Docker Image / build (push) Successful in 3m57s
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 09:47:30 +02:00
MichelleandClaude Fable 5 8c65e4acd2 refactor: replace exceljs with write-excel-file for analytics export
Build & Push Docker Image / build (push) Successful in 3m57s
exceljs (latest 4.4.0) ships years-old transitive dependencies that
npm flags as deprecated on every install (rimraf 2, glob 7, inflight,
fstream, lodash.isequal) and needed a uuid override for a security
advisory. It was only used for the single-sheet analytics XLSX export,
which write-excel-file covers with the same output (column widths,
bold/grey header, formula-injection escaping).

Removes the now-unneeded exceljs uuid override.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 09:40:53 +02:00
MichelleandClaude Fable 5 fcd73d0667 fix: constrain modals to viewport height with internal scrolling
Build & Push Docker Image / build (push) Successful in 4m2s
Modal dialogs (e.g. the create-event form) grew beyond the screen and
scrolled the page behind them. Cap the card at the viewport height and
scroll the body inside it, keeping the header pinned.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 09:33:21 +02:00
MichelleandClaude Fable 5 8830f42ac5 feat: disable AI summary/transcription when room recording is off
- Unchecking "allow recording" in room settings now also clears the
  transcript/AI summary checkbox (it was only greyed out before, so a
  previously enabled value stayed checked and got saved)
- Server enforces the coupling on room create and update: with
  recording disabled, recording_transcript is always stored as 0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 09:32:05 +02:00
MichelleandClaude Fable 5 e7c7dd28d3 chore: update dependencies and fix security vulnerabilities
Build & Push Docker Image / build (push) Successful in 4m1s
- npm update for all semver-compatible packages (vite 8.1.5,
  concurrently 9.2.4, axios 1.18.1, better-sqlite3 12.11.1, ...)
- nodemailer 8 -> 9 (fixes GHSA-p6gq-j5cr-w38f and three further
  advisories: CRLF header injection, jsonTransport/raw file-access
  bypasses, OAuth2 TLS validation)
- override exceljs' nested uuid to ^11.1.1 (GHSA-w5hq-g745-h8pq)
  instead of the breaking exceljs downgrade npm audit suggests
- allow better-sqlite3 install script (npm allowScripts policy)

npm audit: 0 vulnerabilities

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 09:15:28 +02:00
MichelleandClaude Fable 5 69e901f145 feat: send calendar event invitations by email or federation
Build & Push Docker Image / build (push) Successful in 4m18s
- New endpoint POST /api/calendar/events/:id/email sends event
  invitations with an .ics attachment to external email addresses
  (rate-limited like room email invites)
- Create-event dialog gets an optional invitations section to invite
  people by email or federation address right away
- The "Invite remote" dialog on existing events now accepts email
  addresses in addition to federation IDs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 08:58:28 +02:00
14 changed files with 869 additions and 1389 deletions
+519 -1340
View File
File diff suppressed because it is too large Load Diff
+6 -3
View File
@@ -1,7 +1,7 @@
{ {
"name": "redlight", "name": "redlight",
"private": true, "private": true,
"version": "2.4.1", "version": "2.5.0",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"type": "module", "type": "module",
"scripts": { "scripts": {
@@ -19,7 +19,6 @@
"concurrently": "^9.0.0", "concurrently": "^9.0.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^17.3.1", "dotenv": "^17.3.1",
"exceljs": "^4.4.0",
"express": "^5.2.1", "express": "^5.2.1",
"express-rate-limit": "^8.5.2", "express-rate-limit": "^8.5.2",
"flatpickr": "^4.6.13", "flatpickr": "^4.6.13",
@@ -27,7 +26,7 @@
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.0",
"lucide-react": "^1.16.0", "lucide-react": "^1.16.0",
"multer": "^2.1.0", "multer": "^2.1.0",
"nodemailer": "^8.0.1", "nodemailer": "^9.0.3",
"otpauth": "^9.5.0", "otpauth": "^9.5.0",
"pdfkit": "^0.18.0", "pdfkit": "^0.18.0",
"pg": "^8.18.0", "pg": "^8.18.0",
@@ -38,6 +37,7 @@
"react-hot-toast": "^2.4.0", "react-hot-toast": "^2.4.0",
"react-router-dom": "^7.15.1", "react-router-dom": "^7.15.1",
"uuid": "^14.0.0", "uuid": "^14.0.0",
"write-excel-file": "^4.1.1",
"xml2js": "^0.6.0" "xml2js": "^0.6.0"
}, },
"devDependencies": { "devDependencies": {
@@ -48,5 +48,8 @@
"postcss": "^8.4.0", "postcss": "^8.4.0",
"tailwindcss": "^4.3.0", "tailwindcss": "^4.3.0",
"vite": "^8.0.0" "vite": "^8.0.0"
},
"allowScripts": {
"better-sqlite3@12.11.1": true
} }
} }
+72
View File
@@ -289,6 +289,78 @@ export async function sendCalendarInviteEmail(to, name, fromUser, title, startTi
}); });
} }
/**
* Send a calendar event invitation to an external email address (with ICS attachment).
* @param {string} to - recipient email
* @param {string} fromUser - sender display name
* @param {string} title - event title
* @param {string} startTime - ISO start time
* @param {string} endTime - ISO end time
* @param {string|null} description - optional event description
* @param {string|null} joinUrl - direct meeting join URL if a room is linked
* @param {string} ics - ICS file content to attach
* @param {string} appName - branding app name
* @param {string} lang - language code
*/
export async function sendCalendarEventEmail(to, fromUser, title, startTime, endTime, description, joinUrl, ics, appName = 'Redlight', lang = 'en') {
if (!transporter) {
throw new Error('SMTP not configured');
}
const from = process.env.SMTP_FROM || process.env.SMTP_USER;
const headerAppName = sanitizeHeaderValue(appName);
const safeFromUser = escapeHtml(fromUser);
const safeTitle = escapeHtml(title);
const safeDesc = description ? escapeHtml(description) : null;
const formatDate = (iso) => {
try { return new Date(iso).toLocaleString(lang === 'de' ? 'de-DE' : 'en-GB', { dateStyle: 'full', timeStyle: 'short' }); }
catch { return iso; }
};
const introHtml = t(lang, 'email.calendarEventInvite.intro')
.replace('{fromUser}', `<strong style="color:#cdd6f4;">${safeFromUser}</strong>`);
await transporter.sendMail({
from: `"${headerAppName}" <${from}>`,
to,
subject: t(lang, 'email.calendarEventInvite.subject', { appName: headerAppName, title: sanitizeHeaderValue(title) }),
html: `
<div style="font-family:Arial,sans-serif;max-width:520px;margin:0 auto;padding:32px;background:#1e1e2e;color:#cdd6f4;border-radius:12px;">
<h2 style="color:#cba6f7;margin-top:0;">${t(lang, 'email.calendarEventInvite.title')}</h2>
<p>${introHtml}</p>
<div style="background:#313244;border-radius:8px;padding:16px;margin:20px 0;">
<p style="margin:0 0 4px 0;font-size:15px;font-weight:bold;color:#cdd6f4;">${safeTitle}</p>
<p style="margin:6px 0 0 0;font-size:13px;color:#a6adc8;">${escapeHtml(formatDate(startTime))} - ${escapeHtml(formatDate(endTime))}</p>
${safeDesc ? `<p style="margin:10px 0 0 0;font-size:13px;color:#a6adc8;font-style:italic;">&quot;${safeDesc}&quot;</p>` : ''}
</div>
${joinUrl ? `
<p style="text-align:center;margin:28px 0;">
<a href="${joinUrl}"
style="display:inline-block;background:#cba6f7;color:#1e1e2e;padding:12px 32px;border-radius:8px;text-decoration:none;font-weight:bold;">
${t(lang, 'email.calendarEventInvite.joinButton')}
</a>
</p>
<p style="font-size:13px;color:#7f849c;">
${t(lang, 'email.linkHint')}<br/>
<a href="${joinUrl}" style="color:#89b4fa;word-break:break-all;">${escapeHtml(joinUrl)}</a>
</p>` : ''}
<p style="font-size:13px;color:#7f849c;">${t(lang, 'email.calendarEventInvite.icsHint')}</p>
<hr style="border:none;border-top:1px solid #313244;margin:24px 0;"/>
<p style="font-size:12px;color:#585b70;">${t(lang, 'email.calendarEventInvite.footer', { appName: escapeHtml(appName) })}</p>
</div>
`,
text: `${t(lang, 'email.calendarEventInvite.intro', { fromUser })}\n${title}\n${formatDate(startTime)} ${formatDate(endTime)}${description ? `\n\n"${description}"` : ''}${joinUrl ? `\n\n${t(lang, 'email.calendarEventInvite.joinButton')}: ${joinUrl}` : ''}\n\n${t(lang, 'email.calendarEventInvite.icsHint')}\n\n ${appName}`,
attachments: [
{
filename: 'event.ics',
content: ics,
contentType: 'text/calendar; charset=utf-8; method=PUBLISH',
},
],
});
}
/** /**
* Notify a user that a federated calendar event they received was deleted by the organiser. * Notify a user that a federated calendar event they received was deleted by the organiser.
*/ */
+8
View File
@@ -43,6 +43,14 @@
"subject": "{appName} - Kalendereinladung von {fromUser}", "subject": "{appName} - Kalendereinladung von {fromUser}",
"intro": "Du hast eine Kalendereinladung von {fromUser} erhalten." "intro": "Du hast eine Kalendereinladung von {fromUser} erhalten."
}, },
"calendarEventInvite": {
"subject": "{appName} - Kalendereinladung: {title}",
"title": "Kalendereinladung",
"intro": "{fromUser} hat dich zu folgendem Termin eingeladen:",
"joinButton": "Meeting beitreten",
"icsHint": "Mit der angehängten .ics-Datei kannst du den Termin zu deinem Kalender hinzufügen.",
"footer": "Diese Einladung wurde über {appName} versendet."
},
"calendarDeleted": { "calendarDeleted": {
"subject": "{appName} - Kalendereintrag abgesagt: {title}", "subject": "{appName} - Kalendereintrag abgesagt: {title}",
"intro": "Der folgende Kalendereintrag wurde vom Organisator ({fromUser}) gelöscht und ist nicht mehr verfügbar:", "intro": "Der folgende Kalendereintrag wurde vom Organisator ({fromUser}) gelöscht und ist nicht mehr verfügbar:",
+8
View File
@@ -43,6 +43,14 @@
"subject": "{appName} - Calendar invitation from {fromUser}", "subject": "{appName} - Calendar invitation from {fromUser}",
"intro": "You have received a calendar invitation from {fromUser}." "intro": "You have received a calendar invitation from {fromUser}."
}, },
"calendarEventInvite": {
"subject": "{appName} - Calendar invitation: {title}",
"title": "Calendar Invitation",
"intro": "{fromUser} has invited you to the following event:",
"joinButton": "Join Meeting",
"icsHint": "You can add this event to your calendar using the attached .ics file.",
"footer": "This invitation was sent via {appName}."
},
"calendarDeleted": { "calendarDeleted": {
"subject": "{appName} - Calendar event cancelled: {title}", "subject": "{appName} - Calendar event cancelled: {title}",
"intro": "The following calendar event was deleted by the organiser ({fromUser}) and is no longer available:", "intro": "The following calendar event was deleted by the organiser ({fromUser}) and is no longer available:",
+16 -18
View File
@@ -1,6 +1,6 @@
import { Router, json } from 'express'; import { Router, json } from 'express';
import crypto from 'crypto'; import crypto from 'crypto';
import ExcelJS from 'exceljs'; import writeXlsxFile from 'write-excel-file/node';
import PDFDocument from 'pdfkit'; import PDFDocument from 'pdfkit';
import { getDb } from '../config/database.js'; import { getDb } from '../config/database.js';
import { authenticateToken } from '../middleware/auth.js'; import { authenticateToken } from '../middleware/auth.js';
@@ -246,26 +246,24 @@ router.get('/:id/export/:format', authenticateToken, async (req, res) => {
if (format === 'xlsx') { if (format === 'xlsx') {
// Prefix-escape strings that would otherwise be evaluated as formulas. // Prefix-escape strings that would otherwise be evaluated as formulas.
const sanitizeXlsx = (r) => { const sanitizeXlsx = (v) =>
const out = {}; (typeof v === 'string' && /^[=+\-@\t\r]/.test(v)) ? "'" + v : v;
for (const k of Object.keys(r)) {
const v = r[k]; const headerRow = COLUMNS.map(c => ({
out[k] = (typeof v === 'string' && /^[=+\-@\t\r]/.test(v)) ? "'" + v : v; value: c.header,
} fontWeight: 'bold',
return out; backgroundColor: '#e0e0e0',
}; }));
const workbook = new ExcelJS.Workbook(); const dataRows = rows.map(r => COLUMNS.map(c => ({ value: sanitizeXlsx(r[c.key]) })));
const sheet = workbook.addWorksheet('Analytics');
sheet.columns = COLUMNS; const buffer = await writeXlsxFile([headerRow, ...dataRows], {
rows.forEach(r => sheet.addRow(sanitizeXlsx(r))); columns: COLUMNS.map(c => ({ width: c.width })),
// Style header row sheet: 'Analytics',
sheet.getRow(1).font = { bold: true }; }).toBuffer();
sheet.getRow(1).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE0E0E0' } };
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.setHeader('Content-Disposition', `attachment; filename="${safeName}.xlsx"`); res.setHeader('Content-Disposition', `attachment; filename="${safeName}.xlsx"`);
await workbook.xlsx.write(res); return res.send(buffer);
return res.end();
} }
if (format === 'pdf') { if (format === 'pdf') {
+74 -1
View File
@@ -3,7 +3,7 @@ import crypto from 'crypto';
import { getDb } from '../config/database.js'; import { getDb } from '../config/database.js';
import { authenticateToken, getBaseUrl } from '../middleware/auth.js'; import { authenticateToken, getBaseUrl } from '../middleware/auth.js';
import { log } from '../config/logger.js'; import { log } from '../config/logger.js';
import { sendCalendarInviteEmail } from '../config/mailer.js'; import { sendCalendarInviteEmail, sendCalendarEventEmail } from '../config/mailer.js';
import { getAppName } from '../config/appName.js'; import { getAppName } from '../config/appName.js';
import { import {
isFederationEnabled, isFederationEnabled,
@@ -23,6 +23,16 @@ const SAFE_COLOR_RE = /^(?:#[0-9a-fA-F]{3,8}|hsl\(\d{1,3},\s*\d{1,3}%,\s*\d{1,3}
// Allowed reminder intervals in minutes // Allowed reminder intervals in minutes
const VALID_REMINDERS = new Set([5, 15, 30, 60, 120, 1440]); const VALID_REMINDERS = new Set([5, 15, 30, 60, 120, 1440]);
// Rate limit email invitations: each request may carry up to 50 addresses, so
// without a cap any registered account could be abused as an SMTP spam relay.
const calendarEmailInviteLimiter = rateLimit({
windowMs: 60 * 60 * 1000, // 1 hour
max: 10,
standardHeaders: true,
legacyHeaders: false,
message: { error: 'Too many email invitations. Please try again later.' },
});
// Rate limit for federation calendar receive // Rate limit for federation calendar receive
const calendarFederationLimiter = rateLimit({ const calendarFederationLimiter = rateLimit({
windowMs: 15 * 60 * 1000, windowMs: 15 * 60 * 1000,
@@ -581,6 +591,69 @@ router.post('/events/:id/federation', authenticateToken, async (req, res) => {
} }
}); });
// ── POST /api/calendar/events/:id/email — Send event invitation by email ────
router.post('/events/:id/email', authenticateToken, calendarEmailInviteLimiter, async (req, res) => {
try {
const { emails } = req.body;
if (!emails || !Array.isArray(emails) || !emails.length) {
return res.status(400).json({ error: 'At least one email address is required' });
}
if (emails.length > 50) {
return res.status(400).json({ error: 'Maximum 50 email addresses allowed' });
}
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
for (const email of emails) {
if (typeof email !== 'string' || !emailRegex.test(email) || email.length > 254) {
return res.status(400).json({ error: `Invalid email address: ${email}` });
}
}
const db = getDb();
const event = await db.get(`
SELECT ce.*, COALESCE(NULLIF(u.display_name,''), u.name) as organizer_name, u.email as organizer_email
FROM calendar_events ce
JOIN users u ON ce.user_id = u.id
WHERE ce.id = ? AND ce.user_id = ?
`, [req.params.id, req.user.id]);
if (!event) return res.status(404).json({ error: 'Event not found or no permission' });
const baseUrl = getBaseUrl(req);
let joinUrl = null;
if (event.room_uid) {
joinUrl = `${baseUrl}/join/${event.room_uid}`;
}
const ics = generateICS(event, joinUrl || '', baseUrl);
const appName = await getAppName();
const fromUser = req.user.display_name || req.user.name;
const lang = req.user.language || 'en';
// Send emails (in parallel but collect errors)
const results = await Promise.allSettled(
emails.map(email =>
sendCalendarEventEmail(
email, fromUser, event.title, event.start_time, event.end_time,
event.description, joinUrl, ics, appName, lang
)
)
);
const failed = results.filter(r => r.status === 'rejected');
if (failed.length === emails.length) {
return res.status(500).json({ error: 'Failed to send all email invitations' });
}
if (failed.length > 0) {
log.server.warn(`${failed.length}/${emails.length} calendar email invitations failed`);
}
res.json({ success: true, sent: emails.length - failed.length, failed: failed.length });
} catch (err) {
log.server.error(`Calendar email invite error: ${err.message}`);
res.status(500).json({ error: err.message || 'Failed to send email invitations' });
}
});
// ── POST /receive-event or /calendar-event — Receive calendar event from remote ── // ── POST /receive-event or /calendar-event — Receive calendar event from remote ──
// '/receive-event' when mounted at /api/calendar // '/receive-event' when mounted at /api/calendar
// '/calendar-event' when mounted at /api/federation (for remote instance discovery) // '/calendar-event' when mounted at /api/federation (for remote instance discovery)
+1 -1
View File
@@ -41,7 +41,7 @@ export function wellKnownHandler(req, res) {
federation_api: '/api/federation', federation_api: '/api/federation',
public_key: getPublicKey(), public_key: getPublicKey(),
software: 'Redlight', software: 'Redlight',
version: '2.4.1', version: '2.5.0',
}); });
} }
+6 -2
View File
@@ -244,7 +244,8 @@ router.post('/', authenticateToken, async (req, res) => {
record_meeting !== false ? 1 : 0, record_meeting !== false ? 1 : 0,
guest_access ? 1 : 0, guest_access ? 1 : 0,
moderator_code || null, moderator_code || null,
recording_transcript ? 1 : 0, // Transcription/AI summary requires recording to be enabled
(record_meeting !== false && recording_transcript) ? 1 : 0,
]); ]);
const room = await db.get('SELECT * FROM rooms WHERE id = ?', [result.lastInsertRowid]); const room = await db.get('SELECT * FROM rooms WHERE id = ?', [result.lastInsertRowid]);
@@ -306,6 +307,9 @@ router.put('/:uid', authenticateToken, async (req, res) => {
} }
} }
// Transcription/AI summary requires recording — force it off when recording ends up disabled
const effectiveRecordMeeting = record_meeting !== undefined ? !!record_meeting : !!room.record_meeting;
await db.run(` await db.run(`
UPDATE rooms SET UPDATE rooms SET
name = COALESCE(?, name), name = COALESCE(?, name),
@@ -338,7 +342,7 @@ router.put('/:uid', authenticateToken, async (req, res) => {
moderator_code !== undefined ? (moderator_code || null) : room.moderator_code, moderator_code !== undefined ? (moderator_code || null) : room.moderator_code,
learning_analytics !== undefined ? (learning_analytics ? 1 : 0) : null, learning_analytics !== undefined ? (learning_analytics ? 1 : 0) : null,
analytics_visibility && ['owner', 'shared'].includes(analytics_visibility) ? analytics_visibility : null, analytics_visibility && ['owner', 'shared'].includes(analytics_visibility) ? analytics_visibility : null,
recording_transcript !== undefined ? (recording_transcript ? 1 : 0) : null, !effectiveRecordMeeting ? 0 : (recording_transcript !== undefined ? (recording_transcript ? 1 : 0) : null),
req.params.uid, req.params.uid,
]); ]);
+4 -4
View File
@@ -42,10 +42,10 @@ export default function Modal({ title, children, onClose, maxWidth = 'max-w-lg'
aria-modal="true" aria-modal="true"
aria-labelledby={titleId} aria-labelledby={titleId}
tabIndex={-1} tabIndex={-1}
className={`relative bg-th-card rounded-2xl border border-th-border shadow-2xl w-full ${maxWidth} focus:outline-hidden`} className={`relative bg-th-card rounded-2xl border border-th-border shadow-2xl w-full ${maxWidth} max-h-[calc(100vh-2rem)] flex flex-col focus:outline-hidden`}
> >
{/* Header */} {/* Header */}
<div className="flex items-center justify-between px-6 py-4 border-b border-th-border rounded-t-2xl"> <div className="flex items-center justify-between px-6 py-4 border-b border-th-border rounded-t-2xl shrink-0">
<h2 id={titleId} className="text-lg font-semibold text-th-text">{title}</h2> <h2 id={titleId} className="text-lg font-semibold text-th-text">{title}</h2>
<button <button
type="button" type="button"
@@ -56,8 +56,8 @@ export default function Modal({ title, children, onClose, maxWidth = 'max-w-lg'
<X size={20} /> <X size={20} />
</button> </button>
</div> </div>
{/* Body */} {/* Body — scrolls inside the card instead of overflowing the viewport */}
<div className="p-6"> <div className="p-6 overflow-y-auto min-h-0">
{children} {children}
</div> </div>
</div> </div>
+5 -3
View File
@@ -644,9 +644,11 @@
"invitationPending": "Einladung ausstehend", "invitationPending": "Einladung ausstehend",
"pendingInvitations": "Ausstehende Einladungen", "pendingInvitations": "Ausstehende Einladungen",
"accepted": "Angenommen", "accepted": "Angenommen",
"sendFederated": "An Remote senden", "sendFederated": "Remote einladen",
"sendFederatedTitle": "Event an Remote-Instanz senden", "sendFederatedTitle": "Termin-Einladung senden",
"sendFederatedDesc": "Sende dieses Kalender-Event an einen Benutzer auf einer anderen Redlight-Instanz. Der Empfänger muss die Einladung zuerst annehmen, bevor das Event in seinem Kalender erscheint.", "sendFederatedDesc": "Sende dieses Kalender-Event an einen Benutzer auf einer anderen Redlight-Instanz oder an eine beliebige E-Mail-Adresse. Remote-Empfänger müssen die Einladung zuerst annehmen, bevor das Event in ihrem Kalender erscheint; E-Mail-Empfänger erhalten die Termindetails mit einer .ics-Datei im Anhang.",
"inviteSection": "Einladungen versenden (optional)",
"inviteSectionHint": "Lade Personen per E-Mail ein oder sende das Event an einen Benutzer auf einer anderen Redlight-Instanz.",
"send": "Senden", "send": "Senden",
"fedSent": "Kalendereinladung gesendet! Der Empfänger muss diese zuerst annehmen.", "fedSent": "Kalendereinladung gesendet! Der Empfänger muss diese zuerst annehmen.",
"fedFailed": "Event konnte nicht an Remote-Instanz gesendet werden", "fedFailed": "Event konnte nicht an Remote-Instanz gesendet werden",
+5 -3
View File
@@ -644,9 +644,11 @@
"invitationPending": "Invitation pending", "invitationPending": "Invitation pending",
"pendingInvitations": "Pending Invitations", "pendingInvitations": "Pending Invitations",
"accepted": "Accepted", "accepted": "Accepted",
"sendFederated": "Send to remote", "sendFederated": "Invite remote",
"sendFederatedTitle": "Send Event to Remote Instance", "sendFederatedTitle": "Send Event Invitation",
"sendFederatedDesc": "Send this calendar event to a user on another Redlight instance. The recipient must accept the invitation before the event appears in their calendar.", "sendFederatedDesc": "Send this calendar event to a user on another Redlight instance or to any email address. Remote recipients must accept the invitation before the event appears in their calendar; email recipients receive the event details with an .ics attachment.",
"inviteSection": "Send invitations (optional)",
"inviteSectionHint": "Invite people by email or send the event to a user on another Redlight instance.",
"send": "Send", "send": "Send",
"fedSent": "Calendar invitation sent! The recipient must accept it first.", "fedSent": "Calendar invitation sent! The recipient must accept it first.",
"fedFailed": "Could not send event to remote instance", "fedFailed": "Could not send event to remote instance",
+138 -12
View File
@@ -42,8 +42,13 @@ export default function Calendar() {
const [sharedUsers, setSharedUsers] = useState([]); const [sharedUsers, setSharedUsers] = useState([]);
const [pendingInvitations, setPendingInvitations] = useState([]); const [pendingInvitations, setPendingInvitations] = useState([]);
const [fedAddress, setFedAddress] = useState(''); const [fedAddress, setFedAddress] = useState('');
const [fedEmails, setFedEmails] = useState('');
const [fedSending, setFedSending] = useState(false); const [fedSending, setFedSending] = useState(false);
// Invitations sent right after creating an event
const [inviteFedAddress, setInviteFedAddress] = useState('');
const [inviteEmails, setInviteEmails] = useState('');
// Load events on month change // Load events on month change
useEffect(() => { useEffect(() => {
fetchEvents(); fetchEvents();
@@ -159,6 +164,8 @@ export default function Calendar() {
end_time: toLocalDateTimeStr(end), end_time: toLocalDateTimeStr(end),
room_uid: '', color: '#6366f1', reminder_minutes: null, room_uid: '', color: '#6366f1', reminder_minutes: null,
}); });
setInviteFedAddress('');
setInviteEmails('');
setEditingEvent(null); setEditingEvent(null);
setShowCreate(true); setShowCreate(true);
}; };
@@ -178,8 +185,41 @@ export default function Calendar() {
setShowCreate(true); setShowCreate(true);
}; };
const isValidFedAddress = (address) => {
const normalized = address.startsWith('@') ? address.slice(1) : address;
return normalized.includes('@') && !normalized.endsWith('@');
};
// Send invitations for an event; shows a toast per outcome (non-fatal on failure)
const sendEventInvites = async (eventId, address, emailsStr) => {
const addr = address.trim();
if (addr) {
try {
await api.post(`/calendar/events/${eventId}/federation`, { to: addr });
toast.success(t('calendar.fedSent'));
} catch (err) {
toast.error(err.response?.data?.error || t('calendar.fedFailed'));
}
}
const emailList = emailsStr.split(',').map(s => s.trim()).filter(Boolean);
if (emailList.length > 0) {
try {
await api.post(`/calendar/events/${eventId}/email`, { emails: emailList });
toast.success(t('federation.emailSent'));
} catch (err) {
toast.error(err.response?.data?.error || t('federation.emailSendFailed'));
}
}
};
const handleSave = async (e) => { const handleSave = async (e) => {
e.preventDefault(); e.preventDefault();
if (!editingEvent && inviteFedAddress.trim() && !isValidFedAddress(inviteFedAddress.trim())) {
toast.error(t('federation.addressHint'));
return;
}
setSaving(true); setSaving(true);
try { try {
const data = { const data = {
@@ -192,11 +232,17 @@ export default function Calendar() {
await api.put(`/calendar/events/${editingEvent.id}`, data); await api.put(`/calendar/events/${editingEvent.id}`, data);
toast.success(t('calendar.eventUpdated')); toast.success(t('calendar.eventUpdated'));
} else { } else {
await api.post('/calendar/events', data); const res = await api.post('/calendar/events', data);
toast.success(t('calendar.eventCreated')); toast.success(t('calendar.eventCreated'));
const created = res.data.event;
if (created && (inviteFedAddress.trim() || inviteEmails.trim())) {
await sendEventInvites(created.id, inviteFedAddress, inviteEmails);
}
} }
setShowCreate(false); setShowCreate(false);
setEditingEvent(null); setEditingEvent(null);
setInviteFedAddress('');
setInviteEmails('');
fetchEvents(); fetchEvents();
} catch (err) { } catch (err) {
toast.error(err.response?.data?.error || t('calendar.saveFailed')); toast.error(err.response?.data?.error || t('calendar.saveFailed'));
@@ -328,19 +374,41 @@ export default function Calendar() {
const handleFedSend = async (e) => { const handleFedSend = async (e) => {
e.preventDefault(); e.preventDefault();
if (!showFedShare) return; if (!showFedShare) return;
const normalized = fedAddress.startsWith('@') ? fedAddress.slice(1) : fedAddress; const hasAddress = fedAddress.trim().length > 0;
if (!normalized.includes('@') || normalized.endsWith('@')) { const hasEmails = fedEmails.trim().length > 0;
if (!hasAddress && !hasEmails) {
toast.error(t('federation.addressHint')); toast.error(t('federation.addressHint'));
return; return;
} }
setFedSending(true); setFedSending(true);
try { try {
await api.post(`/calendar/events/${showFedShare.id}/federation`, { to: fedAddress }); if (hasAddress) {
toast.success(t('calendar.fedSent')); // Federation address mode
if (!isValidFedAddress(fedAddress.trim())) {
toast.error(t('federation.addressHint'));
setFedSending(false);
return;
}
await api.post(`/calendar/events/${showFedShare.id}/federation`, { to: fedAddress });
toast.success(t('calendar.fedSent'));
} else {
// Email mode
const emailList = fedEmails.split(',').map(s => s.trim()).filter(Boolean);
if (emailList.length === 0) {
toast.error(t('federation.emailHint'));
setFedSending(false);
return;
}
await api.post(`/calendar/events/${showFedShare.id}/email`, { emails: emailList });
toast.success(t('federation.emailSent'));
}
setShowFedShare(null); setShowFedShare(null);
setFedAddress(''); setFedAddress('');
setFedEmails('');
} catch (err) { } catch (err) {
toast.error(err.response?.data?.error || t('calendar.fedFailed')); toast.error(err.response?.data?.error || t(hasAddress ? 'calendar.fedFailed' : 'federation.emailSendFailed'));
} finally { } finally {
setFedSending(false); setFedSending(false);
} }
@@ -378,6 +446,8 @@ export default function Calendar() {
end_time: toLocalDateTimeStr(end), end_time: toLocalDateTimeStr(end),
room_uid: '', color: '#6366f1', room_uid: '', color: '#6366f1',
}); });
setInviteFedAddress('');
setInviteEmails('');
setEditingEvent(null); setEditingEvent(null);
setShowCreate(true); setShowCreate(true);
}} className="btn-primary"> }} className="btn-primary">
@@ -616,6 +686,41 @@ export default function Calendar() {
</div> </div>
</div> </div>
{!editingEvent && (
<div className="pt-4 border-t border-th-border space-y-4">
<div>
<p className="text-sm font-medium text-th-text">{t('calendar.inviteSection')}</p>
<p className="text-xs text-th-text-s mt-0.5">{t('calendar.inviteSectionHint')}</p>
</div>
<div>
<label htmlFor="calendar-invite-emails" className="block text-sm font-medium text-th-text mb-1.5">{t('federation.emailLabel')}</label>
<input
id="calendar-invite-emails"
type="text"
value={inviteEmails}
onChange={e => setInviteEmails(e.target.value)}
className="input-field"
placeholder={t('federation.emailPlaceholder')}
/>
<p className="text-xs text-th-text-s mt-1">{t('federation.emailHint')}</p>
</div>
<div>
<label htmlFor="calendar-invite-fed-address" className="block text-sm font-medium text-th-text mb-1.5">{t('federation.addressLabel')}</label>
<input
id="calendar-invite-fed-address"
type="text"
value={inviteFedAddress}
onChange={e => setInviteFedAddress(e.target.value)}
className="input-field"
placeholder={t('federation.addressPlaceholder')}
/>
<p className="text-xs text-th-text-s mt-1">{t('federation.addressHint')}</p>
</div>
</div>
)}
<div className="flex items-center gap-3 pt-4 border-t border-th-border"> <div className="flex items-center gap-3 pt-4 border-t border-th-border">
<button type="button" onClick={() => { setShowCreate(false); setEditingEvent(null); }} className="btn-secondary flex-1"> <button type="button" onClick={() => { setShowCreate(false); setEditingEvent(null); }} className="btn-secondary flex-1">
{t('common.cancel')} {t('common.cancel')}
@@ -827,9 +932,9 @@ export default function Calendar() {
</Modal> </Modal>
)} )}
{/* Federation Share Modal */} {/* Federation/Email Share Modal */}
{showFedShare && ( {showFedShare && (
<Modal title={t('calendar.sendFederatedTitle')} onClose={() => setShowFedShare(null)}> <Modal title={t('calendar.sendFederatedTitle')} onClose={() => { setShowFedShare(null); setFedAddress(''); setFedEmails(''); }}>
<p className="text-sm text-th-text-s mb-4">{t('calendar.sendFederatedDesc')}</p> <p className="text-sm text-th-text-s mb-4">{t('calendar.sendFederatedDesc')}</p>
<form onSubmit={handleFedSend} className="space-y-4"> <form onSubmit={handleFedSend} className="space-y-4">
<div> <div>
@@ -838,18 +943,39 @@ export default function Calendar() {
id="calendar-fed-share-address" id="calendar-fed-share-address"
type="text" type="text"
value={fedAddress} value={fedAddress}
onChange={e => setFedAddress(e.target.value)} onChange={e => { setFedAddress(e.target.value); if (e.target.value) setFedEmails(''); }}
className="input-field" className="input-field"
placeholder={t('federation.addressPlaceholder')} placeholder={t('federation.addressPlaceholder')}
required disabled={fedEmails.trim().length > 0}
/> />
<p className="text-xs text-th-text-s mt-1">{t('federation.addressHint')}</p> <p className="text-xs text-th-text-s mt-1">{t('federation.addressHint')}</p>
</div> </div>
<div className="flex items-center gap-3 my-2">
<div className="flex-1 border-t border-th-border" />
<span className="text-xs text-th-text-s uppercase">{t('common.or')}</span>
<div className="flex-1 border-t border-th-border" />
</div>
<div>
<label htmlFor="calendar-fed-share-emails" className="block text-sm font-medium text-th-text mb-1.5">{t('federation.emailLabel')}</label>
<input
id="calendar-fed-share-emails"
type="text"
value={fedEmails}
onChange={e => { setFedEmails(e.target.value); if (e.target.value) setFedAddress(''); }}
className="input-field"
placeholder={t('federation.emailPlaceholder')}
disabled={fedAddress.trim().length > 0}
/>
<p className="text-xs text-th-text-s mt-1">{t('federation.emailHint')}</p>
</div>
<div className="flex items-center gap-3 pt-2 border-t border-th-border"> <div className="flex items-center gap-3 pt-2 border-t border-th-border">
<button type="button" onClick={() => setShowFedShare(null)} className="btn-secondary flex-1"> <button type="button" onClick={() => { setShowFedShare(null); setFedAddress(''); setFedEmails(''); }} className="btn-secondary flex-1">
{t('common.cancel')} {t('common.cancel')}
</button> </button>
<button type="submit" disabled={fedSending} className="btn-primary flex-1"> <button type="submit" disabled={fedSending || (!fedAddress.trim() && !fedEmails.trim())} className="btn-primary flex-1">
{fedSending ? <Loader2 size={16} className="animate-spin" /> : <Send size={16} />} {fedSending ? <Loader2 size={16} className="animate-spin" /> : <Send size={16} />}
{t('calendar.send')} {t('calendar.send')}
</button> </button>
+7 -2
View File
@@ -205,7 +205,7 @@ export default function RoomDetail() {
moderator_code: editRoom.moderator_code, moderator_code: editRoom.moderator_code,
learning_analytics: !!editRoom.learning_analytics, learning_analytics: !!editRoom.learning_analytics,
analytics_visibility: editRoom.analytics_visibility || 'owner', analytics_visibility: editRoom.analytics_visibility || 'owner',
recording_transcript: !!editRoom.recording_transcript, recording_transcript: !!editRoom.record_meeting && !!editRoom.recording_transcript,
}); });
setRoom(res.data.room); setRoom(res.data.room);
setEditRoom(res.data.room); setEditRoom(res.data.room);
@@ -674,7 +674,12 @@ export default function RoomDetail() {
<input <input
type="checkbox" type="checkbox"
checked={!!editRoom.record_meeting} checked={!!editRoom.record_meeting}
onChange={e => setEditRoom({ ...editRoom, record_meeting: e.target.checked })} onChange={e => setEditRoom({
...editRoom,
record_meeting: e.target.checked,
// Transcription/AI summary requires recording — clear it when recording is turned off
recording_transcript: e.target.checked ? editRoom.recording_transcript : false,
})}
className="w-4 h-4 rounded-sm border-th-border text-th-accent focus:ring-th-ring" className="w-4 h-4 rounded-sm border-th-border text-th-accent focus:ring-th-ring"
/> />
<span className="text-sm text-th-text">{t('room.allowRecording')}</span> <span className="text-sm text-th-text">{t('room.allowRecording')}</span>