Implement verification panel synchronization with BullMQ integration

- Introduced a new `verificationPanelSync` job to handle posting and updating the verification panel in Discord channels via BullMQ.
- Enhanced the `syncVerificationPanel` function to manage panel updates and error handling, ensuring proper feedback for synchronization issues.
- Updated the WebUI to support verification panel management, including improved error messages for timeout and posting failures.
- Added localization entries for new error messages related to verification panel synchronization in both English and German.
- Refactored existing verification logic to accommodate the new synchronization process, improving overall functionality and user experience.
This commit is contained in:
TheOnlyMace
2026-07-25 15:55:13 +02:00
parent 67ac16d36b
commit ef1803f0ab
10 changed files with 278 additions and 64 deletions

View File

@@ -13,7 +13,15 @@ import { Switch } from '@/components/ui/switch';
import type { SettingsSaveResult } from '@/components/settings/settings-form';
import { SettingsForm } from '@/components/settings/settings-form';
async function saveVerification(guildId: string, value: VerificationConfigDashboard): Promise<SettingsSaveResult> {
async function saveVerification(
guildId: string,
value: VerificationConfigDashboard,
errorMessages: {
timeout: string;
notPosted: string;
network: string;
}
): Promise<SettingsSaveResult> {
try {
const response = await fetch(`/api/guilds/${guildId}/verification`, {
method: 'PATCH',
@@ -21,12 +29,21 @@ async function saveVerification(guildId: string, value: VerificationConfigDashbo
body: JSON.stringify(value)
});
if (!response.ok) {
const body = (await response.json().catch(() => null)) as { error?: string } | null;
const body = (await response.json().catch(() => null)) as {
error?: string;
code?: string;
} | null;
if (body?.code === 'timeout') {
return { ok: false, error: errorMessages.timeout };
}
if (body?.code === 'not_posted') {
return { ok: false, error: errorMessages.notPosted };
}
return { ok: false, error: body?.error ?? `Request failed with status ${response.status}` };
}
return { ok: true };
} catch {
return { ok: false, error: 'Network error' };
return { ok: false, error: errorMessages.network };
}
}
@@ -46,7 +63,13 @@ export function VerificationForm({
return (
<SettingsForm<VerificationConfigDashboard>
initialValue={initialValue}
onSave={(value) => saveVerification(guildId, value)}
onSave={(value) =>
saveVerification(guildId, value, {
timeout: t('modulePages.verification.errors.panelTimeout'),
notPosted: t('modulePages.verification.errors.panelNotPosted'),
network: t('common.networkError')
})
}
>
{({ value, setValue }) => (
<div className="space-y-4">