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');
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"previewTitle": "Nachweis-Vorschau",
|
||||
"closePreview": "Vorschau schließen",
|
||||
"previewUnavailable": "Für diesen Dateityp ist hier keine Vorschau verfügbar.",
|
||||
"documentMissing": "Die Nachweisdatei wurde auf dem Server nicht gefunden.",
|
||||
"empty": "Keine passenden Anfragen gefunden.",
|
||||
"loadError": "Die Freigaben konnten nicht geladen werden.",
|
||||
"updateError": "Der Status konnte nicht geändert werden.",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"previewTitle": "Proof preview",
|
||||
"closePreview": "Close preview",
|
||||
"previewUnavailable": "No inline preview is available for this file type.",
|
||||
"documentMissing": "The verification file was not found on the server.",
|
||||
"empty": "No matching requests found.",
|
||||
"loadError": "Could not load approvals.",
|
||||
"updateError": "Could not update the status.",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"previewTitle": "Vista previa de la prueba",
|
||||
"closePreview": "Cerrar vista previa",
|
||||
"previewUnavailable": "No hay vista previa integrada para este tipo de archivo.",
|
||||
"documentMissing": "El archivo de verificación no se encontró en el servidor.",
|
||||
"empty": "No se han encontrado solicitudes.",
|
||||
"loadError": "No se pudieron cargar las aprobaciones.",
|
||||
"updateError": "No se pudo actualizar el estado.",
|
||||
|
||||
@@ -44,7 +44,15 @@
|
||||
<template v-if="row.adultVerificationRequest">
|
||||
<strong>{{ row.adultVerificationRequest.originalName }}</strong>
|
||||
<span v-if="row.adultVerificationRequest.note">{{ row.adultVerificationRequest.note }}</span>
|
||||
<button type="button" class="secondary" @click="openDocument(row)">
|
||||
<span v-if="!row.adultVerificationDocumentAvailable" class="adult-verification__missing-file">
|
||||
{{ $t('admin.adultVerification.documentMissing') }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="secondary"
|
||||
:disabled="!row.adultVerificationDocumentAvailable"
|
||||
@click="openDocument(row)"
|
||||
>
|
||||
{{ $t('admin.adultVerification.openDocument') }}
|
||||
</button>
|
||||
</template>
|
||||
@@ -149,6 +157,10 @@ export default {
|
||||
}
|
||||
},
|
||||
async openDocument(row) {
|
||||
if (!row.adultVerificationDocumentAvailable) {
|
||||
showApiError(this, null, this.$t('admin.adultVerification.documentMissing'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await apiClient.get(`/api/admin/users/${row.id}/adult-verification/document`, {
|
||||
responseType: 'blob'
|
||||
@@ -269,6 +281,11 @@ export default {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.adult-verification__missing-file {
|
||||
color: #a94442;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.adult-verification__actions .secondary {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user