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

@@ -1,2 +1,3 @@
export { suggestionsCommands } from './commands.js';
export { isSuggestionButton, handleSuggestionButton } from './buttons.js';
export { runSuggestionStatusUpdateJob } from './service.js';

View File

@@ -10,6 +10,7 @@ import { SuggestionStatusSchema, t, tf, type SuggestionStatus } from '@nexumi/sh
import type { Locale } from '@nexumi/shared';
import { ensureGuild } from '../../guild.js';
import { logger } from '../../logger.js';
import { getGuildLocale } from '../../i18n.js';
import type { BotContext } from '../../types.js';
export const SUGGESTION_VOTE_PREFIX = 'sug:vote:';
@@ -339,3 +340,24 @@ export async function updateSuggestionStatus(
await notifyAuthor(context, updated, locale, params.status, params.reason);
return updated;
}
/**
* Entry point for the `suggestionStatusUpdate` BullMQ job, enqueued by the
* WebUI dashboard (which has no discord.js Client to move/edit the
* suggestion embed or DM the author). Resolves the guild's locale and
* delegates to {@link updateSuggestionStatus} so staff actions performed
* from the dashboard behave identically to `/suggestion approve|deny|...`.
*/
export async function runSuggestionStatusUpdateJob(
context: BotContext,
params: {
suggestionId: string;
guildId: string;
status: SuggestionStatus;
reason: string;
}
): Promise<{ id: string }> {
const locale = await getGuildLocale(context.prisma, params.guildId);
const updated = await updateSuggestionStatus(context, params, locale);
return { id: updated.id };
}