mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-04-09 22:20:00 +02:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user