fix config
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
"title": "syui.ai",
|
||||
"did": "did:plc:vzsvtbtbnwn22xjqhcu3vd6y",
|
||||
"handle": "syui.syui.ai",
|
||||
"bot": {
|
||||
"did": "did:plc:6qyecktefllvenje24fcxnie",
|
||||
"handle": "ai.syui.ai"
|
||||
},
|
||||
"collection": "ai.syui.log.post",
|
||||
"network": "syu.is",
|
||||
"color": "#EF454A",
|
||||
|
||||
@@ -223,14 +223,16 @@ fn handle_chat_save(params: ChatSaveParams) -> Result<String> {
|
||||
});
|
||||
|
||||
// Get user DID from token.json
|
||||
let user_did = token::load_session()
|
||||
.map(|s| s.did)
|
||||
.unwrap_or_else(|_| "did:plc:unknown".to_string());
|
||||
let user_did = match token::load_session() {
|
||||
Ok(s) => s.did,
|
||||
Err(_) => return Err(anyhow::anyhow!("User not logged in. Run: ailog login <handle> -p <password>")),
|
||||
};
|
||||
|
||||
// Get bot DID from bot.json
|
||||
let bot_did = token::load_bot_session()
|
||||
.map(|s| s.did)
|
||||
.unwrap_or_else(|_| "did:plc:6qyecktefllvenje24fcxnie".to_string());
|
||||
let bot_did = match token::load_bot_session() {
|
||||
Ok(s) => s.did,
|
||||
Err(_) => return Err(anyhow::anyhow!("Bot not logged in. Run: ailog login <handle> -p <password> --bot")),
|
||||
};
|
||||
|
||||
// Reset session if new_thread requested
|
||||
if params.new_thread {
|
||||
@@ -278,9 +280,10 @@ fn handle_chat_list() -> Result<String> {
|
||||
.to_string()
|
||||
});
|
||||
|
||||
let user_did = token::load_session()
|
||||
.map(|s| s.did)
|
||||
.unwrap_or_else(|_| "did:plc:unknown".to_string());
|
||||
let user_did = match token::load_session() {
|
||||
Ok(s) => s.did,
|
||||
Err(_) => return Err(anyhow::anyhow!("User not logged in. Run: ailog login <handle> -p <password>")),
|
||||
};
|
||||
|
||||
let collection_dir = std::path::Path::new(&output_dir)
|
||||
.join(&user_did)
|
||||
|
||||
@@ -230,13 +230,17 @@ async function render(route: Route): Promise<void> {
|
||||
|
||||
} else if (route.type === 'chat') {
|
||||
// Chat list page - show threads started by this user
|
||||
const aiDid = 'did:plc:6qyecktefllvenje24fcxnie' // ai.syui.ai
|
||||
const aiHandle = 'ai.syui.ai'
|
||||
if (!config.bot) {
|
||||
html += `<div id="content" class="error">Bot not configured in config.json</div>`
|
||||
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
|
||||
} else {
|
||||
const botDid = config.bot.did
|
||||
const botHandle = config.bot.handle
|
||||
|
||||
// Load messages and profiles in parallel
|
||||
const [chatMessages, aiProfile, pds] = await Promise.all([
|
||||
getChatMessages(did, aiDid, 'ai.syui.log.chat'),
|
||||
getProfile(aiDid, false),
|
||||
const [chatMessages, botProfile, pds] = await Promise.all([
|
||||
getChatMessages(did, botDid, 'ai.syui.log.chat'),
|
||||
getProfile(botDid, false),
|
||||
getPds(did)
|
||||
])
|
||||
|
||||
@@ -254,18 +258,23 @@ async function render(route: Route): Promise<void> {
|
||||
langList = Array.from(chatLangs)
|
||||
|
||||
html += renderLangSelector(langList)
|
||||
html += `<div id="content">${renderChatListPage(chatMessages, did, handle, aiDid, aiHandle, profile, aiProfile, pds || undefined)}</div>`
|
||||
html += `<div id="content">${renderChatListPage(chatMessages, did, handle, botDid, botHandle, profile, botProfile, pds || undefined)}</div>`
|
||||
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
|
||||
}
|
||||
|
||||
} else if (route.type === 'chat-thread' && route.rkey) {
|
||||
// Chat thread page - show full conversation
|
||||
const aiDid = 'did:plc:6qyecktefllvenje24fcxnie' // ai.syui.ai
|
||||
const aiHandle = 'ai.syui.ai'
|
||||
if (!config.bot) {
|
||||
html += `<div id="content" class="error">Bot not configured in config.json</div>`
|
||||
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
|
||||
} else {
|
||||
const botDid = config.bot.did
|
||||
const botHandle = config.bot.handle
|
||||
|
||||
// Load messages and profiles in parallel
|
||||
const [chatMessages, aiProfile, pds] = await Promise.all([
|
||||
getChatMessages(did, aiDid, 'ai.syui.log.chat'),
|
||||
getProfile(aiDid, false),
|
||||
const [chatMessages, botProfile, pds] = await Promise.all([
|
||||
getChatMessages(did, botDid, 'ai.syui.log.chat'),
|
||||
getProfile(botDid, false),
|
||||
getPds(did)
|
||||
])
|
||||
|
||||
@@ -283,8 +292,9 @@ async function render(route: Route): Promise<void> {
|
||||
langList = Array.from(chatLangs)
|
||||
|
||||
html += renderLangSelector(langList)
|
||||
html += `<div id="content">${renderChatThreadPage(chatMessages, route.rkey, did, handle, aiDid, aiHandle, profile, aiProfile, pds || undefined)}</div>`
|
||||
html += `<div id="content">${renderChatThreadPage(chatMessages, route.rkey, did, handle, botDid, botHandle, profile, botProfile, pds || undefined)}</div>`
|
||||
html += `<nav class="back-nav"><a href="/@${handle}/at/chat">chat</a></nav>`
|
||||
}
|
||||
|
||||
} else {
|
||||
// User page: compact collection buttons + posts
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
// Config types
|
||||
export interface BotConfig {
|
||||
did: string
|
||||
handle: string
|
||||
}
|
||||
|
||||
export interface AppConfig {
|
||||
title: string
|
||||
did?: string
|
||||
handle: string
|
||||
bot?: BotConfig
|
||||
collection: string
|
||||
network: string
|
||||
color: string
|
||||
|
||||
Reference in New Issue
Block a user