mirror of https://github.com/buster-so/buster.git
fixed the null req message on start chat with asset
This commit is contained in:
parent
294ea785d7
commit
858de8b4fe
|
@ -259,7 +259,7 @@ pub async fn get_chat_handler(
|
||||||
|
|
||||||
let request_message = if let Some(request_message) = msg.request_message {
|
let request_message = if let Some(request_message) = msg.request_message {
|
||||||
Some(ChatUserMessage {
|
Some(ChatUserMessage {
|
||||||
request: request_message,
|
request: Some(request_message),
|
||||||
sender_id: msg.user_id,
|
sender_id: msg.user_id,
|
||||||
sender_name: msg.user_name.unwrap_or_else(|| "Unknown".to_string()),
|
sender_name: msg.user_name.unwrap_or_else(|| "Unknown".to_string()),
|
||||||
sender_avatar,
|
sender_avatar,
|
||||||
|
|
|
@ -292,12 +292,7 @@ pub async fn post_chat_handler(
|
||||||
for message in updated_messages {
|
for message in updated_messages {
|
||||||
let chat_message = ChatMessage::new_with_messages(
|
let chat_message = ChatMessage::new_with_messages(
|
||||||
message.id,
|
message.id,
|
||||||
Some(ChatUserMessage {
|
None,
|
||||||
request: "".to_string(),
|
|
||||||
sender_id: user.id,
|
|
||||||
sender_name: user.name.clone().unwrap_or_default(),
|
|
||||||
sender_avatar: None,
|
|
||||||
}),
|
|
||||||
// Use the response_messages from the DB
|
// Use the response_messages from the DB
|
||||||
serde_json::from_value(message.response_messages).unwrap_or_default(),
|
serde_json::from_value(message.response_messages).unwrap_or_default(),
|
||||||
vec![],
|
vec![],
|
||||||
|
@ -813,7 +808,7 @@ pub async fn post_chat_handler(
|
||||||
let final_message = ChatMessage::new_with_messages(
|
let final_message = ChatMessage::new_with_messages(
|
||||||
message_id,
|
message_id,
|
||||||
Some(ChatUserMessage {
|
Some(ChatUserMessage {
|
||||||
request: request.prompt.clone().unwrap_or_default(),
|
request: request.prompt.clone(),
|
||||||
sender_id: user.id,
|
sender_id: user.id,
|
||||||
sender_name: user.name.clone().unwrap_or_default(),
|
sender_name: user.name.clone().unwrap_or_default(),
|
||||||
sender_avatar: None,
|
sender_avatar: None,
|
||||||
|
@ -2440,7 +2435,7 @@ async fn initialize_chat(
|
||||||
let message = ChatMessage::new_with_messages(
|
let message = ChatMessage::new_with_messages(
|
||||||
message_id,
|
message_id,
|
||||||
Some(ChatUserMessage {
|
Some(ChatUserMessage {
|
||||||
request: prompt_text,
|
request: Some(prompt_text),
|
||||||
sender_id: user.id,
|
sender_id: user.id,
|
||||||
sender_name: user.name.clone().unwrap_or_default(),
|
sender_name: user.name.clone().unwrap_or_default(),
|
||||||
sender_avatar: None,
|
sender_avatar: None,
|
||||||
|
@ -2479,7 +2474,7 @@ async fn initialize_chat(
|
||||||
let message = ChatMessage::new_with_messages(
|
let message = ChatMessage::new_with_messages(
|
||||||
message_id,
|
message_id,
|
||||||
Some(ChatUserMessage {
|
Some(ChatUserMessage {
|
||||||
request: prompt_text,
|
request: Some(prompt_text),
|
||||||
sender_id: user.id,
|
sender_id: user.id,
|
||||||
sender_name: user.name.clone().unwrap_or_default(),
|
sender_name: user.name.clone().unwrap_or_default(),
|
||||||
sender_avatar: None,
|
sender_avatar: None,
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub struct ChatMessage {
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct ChatUserMessage {
|
pub struct ChatUserMessage {
|
||||||
pub request: String,
|
pub request: Option<String>,
|
||||||
pub sender_id: Uuid,
|
pub sender_id: Uuid,
|
||||||
pub sender_name: String,
|
pub sender_name: String,
|
||||||
pub sender_avatar: Option<String>,
|
pub sender_avatar: Option<String>,
|
||||||
|
@ -32,7 +32,7 @@ pub struct ChatUserMessage {
|
||||||
|
|
||||||
impl ChatMessage {
|
impl ChatMessage {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
request: String,
|
request: Option<String>,
|
||||||
sender_id: Uuid,
|
sender_id: Uuid,
|
||||||
sender_name: String,
|
sender_name: String,
|
||||||
sender_avatar: Option<String>,
|
sender_avatar: Option<String>,
|
||||||
|
|
Loading…
Reference in New Issue