feat(admin): enhance adult verification file handling and localization
- Added a new method in AdminService to resolve adult verification file paths, improving file retrieval logic. - Updated the AdminVerificationView to display a message when the verification document is missing. - Localized the missing document message in German, English, and Spanish for better user experience.
This commit is contained in:
@@ -39,6 +39,27 @@ const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
class AdminService {
|
||||
resolveAdultVerificationFile(requestData) {
|
||||
if (!requestData || typeof requestData !== 'object') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const candidates = [];
|
||||
if (requestData.fileName) {
|
||||
candidates.push(path.join(__dirname, '..', 'images', 'adult-verification', requestData.fileName));
|
||||
}
|
||||
if (requestData.storedFileName && requestData.storedFileName !== requestData.fileName) {
|
||||
candidates.push(path.join(__dirname, '..', 'images', 'adult-verification', requestData.storedFileName));
|
||||
}
|
||||
if (requestData.filePath) {
|
||||
candidates.push(path.isAbsolute(requestData.filePath)
|
||||
? requestData.filePath
|
||||
: path.join(__dirname, '..', requestData.filePath));
|
||||
}
|
||||
|
||||
return candidates.find((candidate) => candidate && fs.existsSync(candidate)) || null;
|
||||
}
|
||||
|
||||
removeEroticStorageFile(type, hash) {
|
||||
if (!hash) {
|
||||
return;
|
||||
@@ -302,13 +323,15 @@ class AdminService {
|
||||
} catch {
|
||||
verificationRequest = null;
|
||||
}
|
||||
const resolvedDocumentPath = this.resolveAdultVerificationFile(verificationRequest);
|
||||
return {
|
||||
id: user.hashedId,
|
||||
username: user.username,
|
||||
active: !!user.active,
|
||||
age,
|
||||
adultVerificationStatus: verificationStatus,
|
||||
adultVerificationRequest: verificationRequest
|
||||
adultVerificationRequest: verificationRequest,
|
||||
adultVerificationDocumentAvailable: !!resolvedDocumentPath
|
||||
};
|
||||
}).filter((row) => row.age !== null && row.age >= 18);
|
||||
|
||||
@@ -404,8 +427,8 @@ class AdminService {
|
||||
throw new Error('norequest');
|
||||
}
|
||||
|
||||
const filePath = path.join(__dirname, '..', 'images', 'adult-verification', requestData.fileName);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
const filePath = this.resolveAdultVerificationFile(requestData);
|
||||
if (!filePath) {
|
||||
throw new Error('nofile');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user