Give every user their own bot face
A bot's face and status line live in bot_user_faces, one row per bot and user, set by jobs for the user whose conversation they're in. Needs-you and working only show to that user; every bot read overlays the viewer's face (botFaceSql) and pushes go to the user a face change is for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import BunSQLite from "@moduletrace/bun-sqlite";
|
||||
import type { BUN_SQLITE_COBBLE_BOT_SESSIONS } from "@/db/types/db";
|
||||
import grabBotById from "@/src/functions/backend/db/bots/grab-bot-by-id";
|
||||
import jobSessionId from "@/src/functions/backend/db/bots-queue/job-session-id";
|
||||
import grabJobUserId from "@/src/functions/backend/db/bots-queue/grab-job-user-id";
|
||||
import HarnessError from "@/src/harness/harness-error";
|
||||
import BotJobFatalError from "./bot-job-fatal-error";
|
||||
import runBotReply from "./run-bot-reply";
|
||||
@@ -26,19 +24,13 @@ const runBotJob: BotJobRunner = async (context) => {
|
||||
throw new BotJobFatalError(`The bot for this job no longer exists.`);
|
||||
}
|
||||
|
||||
const session = (
|
||||
await BunSQLite.sql<BUN_SQLITE_COBBLE_BOT_SESSIONS>({
|
||||
sql: `SELECT user_id FROM bot_sessions WHERE id = ? LIMIT 1`,
|
||||
values: [jobSessionId({ job })],
|
||||
})
|
||||
).payload?.[0];
|
||||
const user_id = await grabJobUserId({ job });
|
||||
|
||||
if (!session?.user_id) {
|
||||
if (!user_id) {
|
||||
throw new BotJobFatalError(`The conversation for this job no longer exists.`);
|
||||
}
|
||||
|
||||
const owned = { ...bot, id: bot.id };
|
||||
const user_id = session.user_id;
|
||||
|
||||
try {
|
||||
return job.kind == "reply"
|
||||
|
||||
Reference in New Issue
Block a user