fix: correct import ordering and update tests for drizzle-orm migration
This commit is contained in:
@@ -245,9 +245,7 @@ Satu JSON object per pesan dalam array.`,
|
||||
return { results, raw: response };
|
||||
}
|
||||
|
||||
async function analyzeAndStoreBatch(
|
||||
messages: MessageRecord[],
|
||||
): Promise<void> {
|
||||
async function analyzeAndStoreBatch(messages: MessageRecord[]): Promise<void> {
|
||||
if (messages.length === 0) return;
|
||||
|
||||
const analyzableMessages = messages.filter(
|
||||
@@ -359,9 +357,7 @@ async function drainQueue(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export function queueMessageAnalysis(
|
||||
messageId: string,
|
||||
): void {
|
||||
export function queueMessageAnalysis(messageId: string): void {
|
||||
if (!config.AI_ANALYSIS_ENABLED) return;
|
||||
logger.debug({ messageId }, "Queueing AI analysis");
|
||||
queuedMessageIds.add(messageId);
|
||||
|
||||
@@ -40,9 +40,7 @@ async function syncChannelMessages(
|
||||
return synced;
|
||||
}
|
||||
|
||||
export async function syncBacklogMessages(
|
||||
client: Client,
|
||||
): Promise<void> {
|
||||
export async function syncBacklogMessages(client: Client): Promise<void> {
|
||||
if (!config.MONITOR_GUILD_ID) {
|
||||
logger.warn("MONITOR_GUILD_ID not configured, skipping backlog sync");
|
||||
return;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { Client, Message } from "discord.js-selfbot-v13";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { config } from "../config";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { getDatabase } from "../database/drizzle";
|
||||
import { messagesTable } from "../database/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { queueMessageAnalysis } from "./aiAnalyzer";
|
||||
import {
|
||||
getDisplayContent,
|
||||
@@ -94,9 +94,7 @@ export async function captureMessage(
|
||||
);
|
||||
}
|
||||
|
||||
export function registerMessageCapture(
|
||||
client: Client,
|
||||
): void {
|
||||
export function registerMessageCapture(client: Client): void {
|
||||
client.on("messageCreate", async (message) => {
|
||||
if (!message.guildId || message.guildId !== config.MONITOR_GUILD_ID) return;
|
||||
if (message.author?.bot) return;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { and, asc, desc, eq, isNull, or } from "drizzle-orm";
|
||||
import { getDatabase } from "../database/drizzle";
|
||||
import { messagesTable, attachmentsTable } from "../database/schema";
|
||||
import { eq, or, desc, asc, and, isNull } from "drizzle-orm";
|
||||
import { attachmentsTable, messagesTable } from "../database/schema";
|
||||
import { createChildLogger } from "../logger";
|
||||
import type { AttachmentRecord, MessageRecord } from "./types";
|
||||
|
||||
const logger = createChildLogger("message-store");
|
||||
|
||||
export async function insertMessage(
|
||||
message: MessageRecord,
|
||||
): Promise<void> {
|
||||
export async function insertMessage(message: MessageRecord): Promise<void> {
|
||||
try {
|
||||
const db = getDatabase() as any;
|
||||
await db.insert(messagesTable).values(message).onConflictDoNothing();
|
||||
|
||||
Reference in New Issue
Block a user