Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 364
feat(web): replace placeholder avatars with minidenticon-based UserAvatar#1072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
3ca263146d97c12476c85b3df5580d9aa3612a0661File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| 'use server'; | ||
| import { minidenticon } from 'minidenticons'; | ||
| import sharp from 'sharp'; | ||
| import { NextRequest } from 'next/server'; | ||
| import { apiHandler } from '@/lib/apiHandler'; | ||
| // Generates a minidenticon avatar PNG from an email address. | ||
| // Used as a fallback avatar in emails where data URIs aren't supported. | ||
| export const GET = apiHandler(async (request: NextRequest) => { | ||
| const email = request.nextUrl.searchParams.get('email'); | ||
| if (!email) { | ||
| return new Response('Missing email parameter', { status: 400 }); | ||
| } | ||
brendan-kellam marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const svg = minidenticon(email, 50, 50); | ||
| const png = await sharp(Buffer.from(svg)) | ||
brendan-kellam marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| .flatten({ background: { r: 241, g: 245, b: 249 } }) | ||
| .resize(128, 128) | ||
| .png() | ||
| .toBuffer(); | ||
| return new Response(new Uint8Array(png), { | ||
| headers: { | ||
| 'Content-Type': 'image/png', | ||
| 'Cache-Control': 'public, max-age=31536000, immutable', | ||
| }, | ||
| }); | ||
| }, { track: false }); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.