Replace 'Unknown' user name fallback with email address

- Update Rust handlers to use user_email instead of 'Unknown' fallback
- Add user_email field to MessageWithUser and ChatWithUser structs
- Update database queries to select user email field
- Update TypeScript chat-helpers to use email fallback
- Maintain final fallback to 'Unknown'/'Unknown User' if email is null

Fixes BUS-1457

Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
Devin AI 2025-07-19 04:12:13 +00:00
parent ba04450469
commit 9896b5cc90
4 changed files with 13 additions and 6 deletions

View File

@ -43,6 +43,7 @@ pub struct MessageWithUser {
pub updated_at: DateTime<Utc>,
pub user_id: Uuid,
pub user_name: Option<String>,
pub user_email: String,
pub user_avatar_url: Option<String>,
pub feedback: Option<String>,
pub is_completed: bool,
@ -137,6 +138,7 @@ pub async fn get_chat_handler(
messages::updated_at,
users::id,
users::name.nullable(),
users::email,
users::avatar_url.nullable(),
messages::feedback.nullable(),
messages::is_completed,
@ -274,7 +276,7 @@ pub async fn get_chat_handler(
Some(ChatUserMessage {
request: Some(request_message),
sender_id: msg.user_id,
sender_name: msg.user_name.unwrap_or_else(|| "Unknown".to_string()),
sender_name: msg.user_name.unwrap_or_else(|| msg.user_email.clone()),
sender_avatar: msg.user_avatar_url,
})
} else {
@ -353,7 +355,7 @@ pub async fn get_chat_handler(
thread_messages,
false, // is_favorited not implemented in current schema
thread.user_id.to_string(),
thread.user_name.unwrap_or_else(|| "Unknown".to_string()),
thread.user_name.unwrap_or_else(|| thread.user_email.clone()),
created_by_avatar,
);

View File

@ -63,6 +63,7 @@ struct ChatWithUser {
pub most_recent_version_number: Option<i32>,
// User fields
pub user_name: Option<String>,
pub user_email: String,
pub user_avatar_url: Option<String>,
}
@ -144,6 +145,7 @@ pub async fn list_chats_handler(
chats::most_recent_file_type,
chats::most_recent_version_number,
users::name.nullable(),
users::email,
users::avatar_url.nullable(),
))
.load::<ChatWithUser>(&mut conn)
@ -235,6 +237,7 @@ pub async fn list_chats_handler(
chats::most_recent_file_type,
chats::most_recent_version_number,
users::name.nullable(),
users::email,
users::avatar_url.nullable(),
))
.order_by(chats::updated_at.desc())
@ -258,7 +261,7 @@ pub async fn list_chats_handler(
updated_at: chat.updated_at.to_rfc3339(),
created_by: chat.created_by.to_string(),
created_by_id: chat.created_by.to_string(),
created_by_name: chat.user_name.unwrap_or_else(|| "Unknown".to_string()),
created_by_name: chat.user_name.unwrap_or_else(|| chat.user_email.clone()),
created_by_avatar: chat.user_avatar_url,
last_edited: chat.updated_at.to_rfc3339(),
latest_file_id: chat.most_recent_file_id.map(|id| id.to_string()),
@ -280,7 +283,7 @@ pub async fn list_chats_handler(
updated_at: chat.updated_at.to_rfc3339(),
created_by: chat.created_by.to_string(),
created_by_id: chat.created_by.to_string(),
created_by_name: chat.user_name.unwrap_or_else(|| "Unknown".to_string()),
created_by_name: chat.user_name.unwrap_or_else(|| chat.user_email.clone()),
created_by_avatar: chat.user_avatar_url,
last_edited: chat.updated_at.to_rfc3339(),
latest_file_id: chat.most_recent_file_id.map(|id| id.to_string()),

View File

@ -55,6 +55,7 @@ struct ChatWithUser {
pub most_recent_version_number: Option<i32>,
// User fields
pub user_name: Option<String>,
pub user_email: String,
pub user_avatar_url: Option<String>,
}
@ -116,6 +117,7 @@ pub async fn list_logs_handler(
chats::most_recent_file_type,
chats::most_recent_version_number,
users::name.nullable(),
users::email,
users::avatar_url.nullable(),
))
.load::<ChatWithUser>(&mut conn)
@ -135,7 +137,7 @@ pub async fn list_logs_handler(
updated_at: chat.updated_at.to_rfc3339(),
created_by: chat.created_by.to_string(),
created_by_id: chat.created_by.to_string(),
created_by_name: chat.user_name.unwrap_or_else(|| "Unknown".to_string()),
created_by_name: chat.user_name.unwrap_or_else(|| chat.user_email.clone()),
created_by_avatar: chat.user_avatar_url,
last_edited: chat.updated_at.to_rfc3339(),
latest_file_id: chat.most_recent_file_id.map(|id| id.to_string()),

View File

@ -114,7 +114,7 @@ export function buildChatWithMessages(
const messageIds: string[] = new Array(messageCount);
// Cache user info to avoid repeated property access
const userName = user?.name || 'Unknown User';
const userName = user?.name || user?.email || 'Unknown User';
const userAvatar = user?.avatarUrl || undefined;
// Single iteration with optimized object creation