refactor: resolve architecture disconnects and codebase weaknesses
- Consolidate eventTypes.ts as single source of truth for Redis channels: - Remove duplicate DiscordGatewayEvent interface from eventBroadcaster.ts - Replace all hardcoded channel strings with EventChannels constants - eventTypes.ts is no longer an orphan file - Remove dangerous moderation action feature (selfbot safety): - Remove /messages/:id/moderate endpoint from backend - Remove moderation:action handler from commandHandler.ts - Remove publishFireAndForgetCommand (wrong envelope format) - Verified no remaining references to moderation:action in code - Remove unused getCommandPublisher import from redis-bridge.ts Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
3614d32701
commit
7d6612bb2d
@@ -1,7 +1,6 @@
|
||||
import { createChildLogger } from "@bete/shared/logger";
|
||||
import Redis from "ioredis";
|
||||
import { config } from "../shared/config/index.js";
|
||||
import { getCommandPublisher } from "../shared/redis/index.js";
|
||||
import { broadcastRaw } from "./broadcast.js";
|
||||
|
||||
const logger = createChildLogger("ws.redis-bridge");
|
||||
@@ -35,24 +34,6 @@ function createSubscriber(): Redis {
|
||||
return new Redis(config.REDIS_URL, { keyPrefix: "" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a command to the Discord Gateway via Redis.
|
||||
* The DG's commandHandler listens on "backend:command" channel.
|
||||
*/
|
||||
export async function publishCommand(
|
||||
payload: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
const pub = getCommandPublisher();
|
||||
const envelope = {
|
||||
type: "command",
|
||||
data: payload,
|
||||
timestamp: Date.now(),
|
||||
source: "backend",
|
||||
};
|
||||
await pub.publish("backend:command", JSON.stringify(envelope));
|
||||
logger.debug({ payload }, "Published command to DG");
|
||||
}
|
||||
|
||||
function handleSubscriptionMessage(channel: string, message: string): void {
|
||||
const mapping = SUBSCRIPTIONS.find((m) => m.channel === channel);
|
||||
if (!mapping) {
|
||||
|
||||
Reference in New Issue
Block a user