Merge branch 'main' into add_booking_confirmed_webhook_event

add_booking_confirmed_webhook_event
kodiakhq[bot] 2022-01-12 13:07:26 +00:00 committed by GitHub
commit 91e2b49c5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -22,7 +22,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
.update(user?.email as string)
.digest("hex");
const img = user?.avatar;
if (img) {
if (!img) {
res.writeHead(302, {
Location: defaultAvatarSrc({ md5: emailMd5 }),
});
res.end();
} else if (!img.includes("data:image")) {
res.writeHead(302, {
Location: img,
});
res.end();
} else {
const decoded = img
.toString()
.replace("data:image/png;base64,", "")
@ -33,10 +43,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
"Content-Length": imageResp.length,
});
res.end(imageResp);
} else {
res.writeHead(302, {
Location: defaultAvatarSrc({ md5: emailMd5 }),
});
res.end();
}
}