add avatar support for BBB
All checks were successful
Build & Push Docker Image / build (push) Successful in 1m10s

This commit is contained in:
2026-02-24 19:05:41 +01:00
parent cf74ed31af
commit 9001aea8cd
5 changed files with 51 additions and 4 deletions

View File

@@ -12,6 +12,16 @@ import {
const router = Router();
// Build avatar URL for a user (uploaded image or generated initials)
function getUserAvatarURL(req, user) {
const baseUrl = `${req.protocol}://${req.get('host')}`;
if (user.avatar_image) {
return `${baseUrl}/api/auth/avatar/${user.avatar_image}`;
}
const color = user.avatar_color ? `?color=${encodeURIComponent(user.avatar_color)}` : '';
return `${baseUrl}/api/auth/avatar/initials/${encodeURIComponent(user.name)}${color}`;
}
// GET /api/rooms - List user's rooms
router.get('/', authenticateToken, async (req, res) => {
try {
@@ -199,7 +209,8 @@ router.post('/:uid/start', authenticateToken, async (req, res) => {
}
await createMeeting(room, `${req.protocol}://${req.get('host')}`);
const joinUrl = await joinMeeting(room.uid, req.user.name, true);
const avatarURL = getUserAvatarURL(req, req.user);
const joinUrl = await joinMeeting(room.uid, req.user.name, true, avatarURL);
res.json({ joinUrl });
} catch (err) {
console.error('Start meeting error:', err);
@@ -229,7 +240,8 @@ router.post('/:uid/join', authenticateToken, async (req, res) => {
}
const isModerator = room.user_id === req.user.id || room.all_join_moderator;
const joinUrl = await joinMeeting(room.uid, req.user.name, isModerator);
const avatarURL = getUserAvatarURL(req, req.user);
const joinUrl = await joinMeeting(room.uid, req.user.name, isModerator, avatarURL);
res.json({ joinUrl });
} catch (err) {
console.error('Join meeting error:', err);
@@ -335,7 +347,9 @@ router.post('/:uid/guest-join', async (req, res) => {
isModerator = true;
}
const joinUrl = await joinMeeting(room.uid, name.trim(), isModerator);
const baseUrl = `${req.protocol}://${req.get('host')}`;
const guestAvatarURL = `${baseUrl}/api/auth/avatar/initials/${encodeURIComponent(name.trim())}`;
const joinUrl = await joinMeeting(room.uid, name.trim(), isModerator, guestAvatarURL);
res.json({ joinUrl });
} catch (err) {
console.error('Guest join error:', err);