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:
@@ -1,4 +1,8 @@
|
||||
import type { SocialFeedDashboard, SocialFeedDashboardCreate, SocialFeedDashboardUpdate } from '@nexumi/shared';
|
||||
import type {
|
||||
SocialFeedDashboard,
|
||||
SocialFeedDashboardCreate,
|
||||
SocialFeedDashboardUpdate
|
||||
} from '@nexumi/shared';
|
||||
import type { SocialFeed } from '@prisma/client';
|
||||
import { prisma } from '../prisma';
|
||||
|
||||
@@ -14,12 +18,15 @@ function toDashboard(feed: SocialFeed): SocialFeedDashboard {
|
||||
};
|
||||
}
|
||||
|
||||
export async function listSocialFeeds(guildId: string): Promise<SocialFeedDashboard[]> {
|
||||
const feeds = await prisma.socialFeed.findMany({ where: { guildId }, orderBy: { createdAt: 'asc' } });
|
||||
export async function listFeeds(guildId: string): Promise<SocialFeedDashboard[]> {
|
||||
const feeds = await prisma.socialFeed.findMany({
|
||||
where: { guildId },
|
||||
orderBy: { createdAt: 'asc' }
|
||||
});
|
||||
return feeds.map(toDashboard);
|
||||
}
|
||||
|
||||
export async function createSocialFeed(
|
||||
export async function createFeed(
|
||||
guildId: string,
|
||||
input: SocialFeedDashboardCreate
|
||||
): Promise<SocialFeedDashboard> {
|
||||
@@ -30,7 +37,7 @@ export async function createSocialFeed(
|
||||
type: input.type,
|
||||
sourceId: input.sourceId,
|
||||
channelId: input.channelId,
|
||||
rolePingId: input.rolePingId ? input.rolePingId : null,
|
||||
rolePingId: input.rolePingId || null,
|
||||
template: input.template ?? null,
|
||||
enabled: input.enabled
|
||||
}
|
||||
@@ -38,7 +45,7 @@ export async function createSocialFeed(
|
||||
return toDashboard(feed);
|
||||
}
|
||||
|
||||
export async function updateSocialFeed(
|
||||
export async function updateFeed(
|
||||
guildId: string,
|
||||
feedId: string,
|
||||
patch: SocialFeedDashboardUpdate
|
||||
@@ -59,7 +66,11 @@ export async function updateSocialFeed(
|
||||
return toDashboard(updated);
|
||||
}
|
||||
|
||||
export async function deleteSocialFeed(guildId: string, feedId: string): Promise<boolean> {
|
||||
const result = await prisma.socialFeed.deleteMany({ where: { id: feedId, guildId } });
|
||||
return result.count > 0;
|
||||
export async function deleteFeed(guildId: string, feedId: string): Promise<boolean> {
|
||||
const existing = await prisma.socialFeed.findFirst({ where: { id: feedId, guildId } });
|
||||
if (!existing) {
|
||||
return false;
|
||||
}
|
||||
await prisma.socialFeed.delete({ where: { id: feedId } });
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user