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:
@@ -9,7 +9,10 @@ import type { BotContext } from './types.js';
|
||||
import { env } from './env.js';
|
||||
import { refreshPhishingDomains } from './modules/automod/filters.js';
|
||||
import { activateLockdown, deactivateLockdown } from './modules/automod/actions.js';
|
||||
import { completeVerification } from './modules/verification/handlers.js';
|
||||
import {
|
||||
completeVerification,
|
||||
runVerificationPanelSyncJob
|
||||
} from './modules/verification/handlers.js';
|
||||
import { closePoll } from './modules/utility/poll.js';
|
||||
import { sendReminder } from './modules/utility/reminders.js';
|
||||
import {
|
||||
@@ -84,6 +87,10 @@ type VerificationCompleteJob = {
|
||||
captchaProvider?: string | null;
|
||||
};
|
||||
|
||||
type VerificationPanelSyncJob = {
|
||||
guildId: string;
|
||||
};
|
||||
|
||||
type ReminderSendJob = {
|
||||
reminderId: string;
|
||||
};
|
||||
@@ -297,16 +304,20 @@ export function startWorkers(context: BotContext): Worker[] {
|
||||
logger.error({ jobId: job?.id, error }, 'AutoMod job failed');
|
||||
});
|
||||
|
||||
const verificationWorker = new Worker<VerificationCompleteJob>(
|
||||
const verificationWorker = new Worker<VerificationCompleteJob | VerificationPanelSyncJob>(
|
||||
verificationQueueName,
|
||||
async (job) => {
|
||||
if (job.name === 'verificationPanelSync') {
|
||||
return runVerificationPanelSyncJob(context, job.data as VerificationPanelSyncJob);
|
||||
}
|
||||
if (job.name !== 'verificationComplete') {
|
||||
return;
|
||||
}
|
||||
await completeVerification(context, job.data.guildId, job.data.userId, {
|
||||
ipHash: job.data.ipHash,
|
||||
userAgentHash: job.data.userAgentHash,
|
||||
captchaProvider: job.data.captchaProvider
|
||||
const data = job.data as VerificationCompleteJob;
|
||||
await completeVerification(context, data.guildId, data.userId, {
|
||||
ipHash: data.ipHash,
|
||||
userAgentHash: data.userAgentHash,
|
||||
captchaProvider: data.captchaProvider
|
||||
});
|
||||
},
|
||||
{ connection: redis }
|
||||
|
||||
Reference in New Issue
Block a user