Add suggestion status update job and queue integration

- Introduced a new `SuggestionStatusUpdateJob` type and corresponding worker to handle suggestion status updates in the bot's job processing.
- Added `suggestionsQueue` and `suggestionsQueueEvents` for managing suggestion-related jobs in both the bot and WebUI.
- Implemented `runSuggestionStatusUpdateJob` to facilitate staff actions on suggestions via the WebUI, ensuring consistent behavior with existing commands.
- Enhanced error handling for suggestion actions to improve user experience and reliability.
This commit is contained in:
smueller
2026-07-22 15:39:31 +02:00
parent 0ac69ee840
commit 47b6cfabbc
16 changed files with 773 additions and 23 deletions

View File

@@ -19,6 +19,7 @@ import { ensureStatsRecurringJobs, startStatsWorker } from './modules/stats/inde
import { pollAllFeeds } from './modules/feeds/index.js';
import { sendScheduledMessage } from './modules/scheduler/index.js';
import { runGuildBackupRestoreJob } from './modules/guildbackup/index.js';
import { runSuggestionStatusUpdateJob } from './modules/suggestions/index.js';
import {
automodQueue,
automodQueueName,
@@ -33,6 +34,7 @@ import {
moderationQueueName,
reminderQueueName,
scheduleQueueName,
suggestionsQueueName,
ticketQueue,
ticketQueueName,
verificationQueueName
@@ -95,6 +97,13 @@ type BirthdayRoleExpireJob = {
roleId: string;
};
type SuggestionStatusUpdateJob = {
suggestionId: string;
guildId: string;
status: 'OPEN' | 'APPROVED' | 'DENIED' | 'CONSIDERED' | 'IMPLEMENTED';
reason: string;
};
export function startWorkers(context: BotContext): Worker[] {
const moderationWorker = new Worker<TempBanJob>(
moderationQueueName,
@@ -281,6 +290,20 @@ export function startWorkers(context: BotContext): Worker[] {
logger.error({ jobId: job?.id, error }, 'Guild backup restore job failed');
});
const suggestionsWorker = new Worker<SuggestionStatusUpdateJob>(
suggestionsQueueName,
async (job) => {
if (job.name !== 'suggestionStatusUpdate') {
return;
}
return runSuggestionStatusUpdateJob(context, job.data);
},
{ connection: redis }
);
suggestionsWorker.on('failed', (job, error) => {
logger.error({ jobId: job?.id, error }, 'Suggestion status update job failed');
});
return [
moderationWorker,
backupWorker,
@@ -293,7 +316,8 @@ export function startWorkers(context: BotContext): Worker[] {
statsWorker,
feedsWorker,
scheduleWorker,
guildBackupWorker
guildBackupWorker,
suggestionsWorker
];
}