(fix) user banners cache doesn't get invalidated after chaging avatar

This commit is contained in:
Andrea Vos 2024-03-17 13:18:34 +01:00
parent c56c59abf1
commit a690f33a2e

View File

@ -18,6 +18,7 @@ import copyAvatar from '../avatarCopy.js';
import { usernameRegex, usernameUnsafeRegex } from '../../src/username.ts';
const config = loadSuml('config');
import auditLog from '../audit.ts';
import {CacheObject} from "../../src/cache.js";
export const normalise = (s) => s.trim().toLowerCase();
@ -723,6 +724,8 @@ router.post('/user/set-avatar', handleErrorAsync(async (req, res) => {
await resetCards(req.db, req.user.id);
await new CacheObject('banner', `@${req.user.username}.png`, 24 * 60).invalidate();
await auditLog(req, 'auth/changed_avatar', { source: req.body.source });
return res.json({ token: await issueAuthentication(req.db, req.user) });