feat: allow 3 profile pics (#14092)

* feat: allow 3 profile pics

* test: fix notification test

* test: fix user picture test

* test: relative_path fixes

* fix: relative_path getting saved in when updating profile pic
This commit is contained in:
Barış Uşaklı
2026-03-13 18:42:50 -04:00
committed by GitHub
parent d1e1a0082d
commit 533ae69c46
10 changed files with 194 additions and 138 deletions

View File

@@ -2,7 +2,7 @@
const path = require('path');
const fs = require('fs').promises;
const nconf = require('nconf');
const validator = require('validator');
const winston = require('winston');
@@ -627,7 +627,14 @@ usersAPI.changePicture = async (caller, data) => {
if (type === 'default') {
picture = '';
} else if (type === 'uploaded') {
picture = await user.getUserField(data.uid, 'uploadedpicture');
const cleanPath = data.picture.replace(new RegExp(`^${nconf.get('relative_path')}`), '');
const isUserPicture = await user.isUserUploadedPicture(data.uid, cleanPath);
if (isUserPicture) {
await user.setUserField(data.uid, 'uploadedpicture', cleanPath);
picture = cleanPath;
} else {
picture = '';
}
} else if (type === 'external' && url) {
picture = validator.escape(url);
} else {