Add VoiceScripts and VoiceSubmissions collections, voiceover event types and event-log targets, the voice-submissions migration, and a voiceover XP group on Profiles counted toward total XP. Ultraworked with [Sisyphus](https://github.com/code-yeongju/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
import type { EventType } from "./eventTypes";
|
|
import { broadcast } from "@/lib/realtime/bus";
|
|
|
|
interface GameEventInput {
|
|
type: EventType;
|
|
message: string;
|
|
actor?: number;
|
|
structure?: number;
|
|
targetCollection?:
|
|
| "users"
|
|
| "missions"
|
|
| "maps"
|
|
| "campaigns"
|
|
| "factions"
|
|
| "technologies"
|
|
| "assets"
|
|
| "resources"
|
|
| "structures"
|
|
| "vehicles"
|
|
| "game-structures"
|
|
| "game-vehicles"
|
|
| "game-npcs"
|
|
| "npc-staffing"
|
|
| "shipments"
|
|
| "bank-accounts"
|
|
| "bank-transactions"
|
|
| "ledger-entries"
|
|
| "locker-storages"
|
|
| "loadouts"
|
|
| "market-listings"
|
|
| "market-negotiations"
|
|
| "evaluations"
|
|
| "tickets"
|
|
| "wiki-pages"
|
|
| "wiki-revisions"
|
|
| "wiki-templates"
|
|
| "game-servers"
|
|
| "assignment-transfers"
|
|
| "market-state"
|
|
| "voice-scripts"
|
|
| "voice-submissions";
|
|
targetId?: number;
|
|
data?: Record<string, unknown>;
|
|
}
|
|
|
|
export async function emitGameEvent(
|
|
payload: Awaited<ReturnType<typeof import("payload").getPayload>>,
|
|
event: GameEventInput,
|
|
) {
|
|
try {
|
|
await payload.create({
|
|
collection: "game-event-logs",
|
|
data: {
|
|
system: true,
|
|
timestamp: new Date().toISOString(),
|
|
type: event.type,
|
|
actor: event.actor,
|
|
message: event.message,
|
|
data: event.data,
|
|
targetCollection: event.targetCollection,
|
|
targetId: event.targetId,
|
|
structure: event.structure,
|
|
},
|
|
depth: 0,
|
|
// Bins and tests run without an authenticated user; create access on
|
|
// game-event-logs requires one, so system events would be silently dropped.
|
|
overrideAccess: true,
|
|
});
|
|
broadcast("game-event", {
|
|
type: event.type,
|
|
actor: event.actor ?? null,
|
|
targetCollection: event.targetCollection ?? null,
|
|
targetId: event.targetId ?? null,
|
|
});
|
|
} catch (err) {
|
|
console.error("[EventLog] Failed to emit event:", err);
|
|
}
|
|
}
|