[profile] load proper avatar source in banner

This commit is contained in:
Andrea Vos 2020-11-04 17:41:31 +01:00
parent 79bf31683e
commit f16c40d2fb
2 changed files with 6 additions and 6 deletions

View File

@ -779,9 +779,9 @@ terms:
admin:
header: 'Panel adminia'
user:
user: 'Użytkownik'
user: 'Użytkownicze'
email: 'Email'
roles: 'Role'
roles: 'Rola'
profiles: 'Profile'
confirmRole: 'Czy na pewno chcesz zmienić rolę osoby @%username% na "%role%"?'

View File

@ -2,7 +2,7 @@ import { Router } from 'express';
import SQL from 'sql-template-strings';
import {createCanvas, loadImage, registerFont} from "canvas";
import translations from "../translations";
import {gravatar} from "../../src/helpers";
import avatar from '../avatar';
import {buildTemplate, parseTemplates} from "../../src/buildTemplate";
import {loadTsv} from "../../src/tsv";
@ -51,15 +51,15 @@ router.get('/banner/:templateName*.png', async (req, res) => {
}
if (templateName.startsWith('@')) {
const user = await req.db.get(SQL`SELECT username, email FROM users WHERE username=${templateName.substring(1)}`);
const user = await req.db.get(SQL`SELECT id, username, email, avatarSource FROM users WHERE username=${templateName.substring(1)}`);
if (!user) {
await fallback();
return res.set('content-type', mime).send(canvas.toBuffer(mime));
}
const avatar = await loadImage(gravatar(user, imageSize));
const avatarImage = await loadImage(await avatar(req.db, user));
drawCircle(context, avatar, width / leftRatio - imageSize / 2, height / 2 - imageSize / 2, imageSize);
drawCircle(context, avatarImage, width / leftRatio - imageSize / 2, height / 2 - imageSize / 2, imageSize);
context.font = `regular 48pt Quicksand`
context.fillText('@' + user.username, width / leftRatio + imageSize, height / 2)