added profile pictures to messages and improved chat page layout
This commit is contained in:
@@ -17,15 +17,17 @@ use crate::{
|
|||||||
pub struct MessageRow {
|
pub struct MessageRow {
|
||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub sender: String,
|
pub sender: String,
|
||||||
|
pub sender_uuid: Uuid,
|
||||||
pub message_type: String,
|
pub message_type: String,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub sent_at: chrono::NaiveDateTime,
|
pub sent_at: chrono::NaiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(sqlx::FromRow, serde::Serialize, Debug, Clone)]
|
#[derive(serde::Serialize, Debug, Clone)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub sender: String,
|
pub sender: String,
|
||||||
|
pub sender_uuid: Uuid,
|
||||||
pub message_type: String,
|
pub message_type: String,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub sent_at: String,
|
pub sent_at: String,
|
||||||
@@ -74,6 +76,7 @@ async fn list_messages(
|
|||||||
SELECT
|
SELECT
|
||||||
m.uuid,
|
m.uuid,
|
||||||
u.username AS sender,
|
u.username AS sender,
|
||||||
|
u.uuid AS sender_uuid,
|
||||||
r.uuid AS room,
|
r.uuid AS room,
|
||||||
m.message_type,
|
m.message_type,
|
||||||
m.content,
|
m.content,
|
||||||
@@ -104,6 +107,7 @@ async fn list_messages(
|
|||||||
.map(|m| Message {
|
.map(|m| Message {
|
||||||
uuid: m.uuid,
|
uuid: m.uuid,
|
||||||
sender: m.sender,
|
sender: m.sender,
|
||||||
|
sender_uuid: m.sender_uuid,
|
||||||
message_type: m.message_type,
|
message_type: m.message_type,
|
||||||
content: m.content,
|
content: m.content,
|
||||||
sent_at: m.sent_at.format("%Y-%m-%d %H:%M:%S").to_string(),
|
sent_at: m.sent_at.format("%Y-%m-%d %H:%M:%S").to_string(),
|
||||||
@@ -154,6 +158,7 @@ async fn create_message(
|
|||||||
let message = Message {
|
let message = Message {
|
||||||
uuid: uuid,
|
uuid: uuid,
|
||||||
sender: sender_name,
|
sender: sender_name,
|
||||||
|
sender_uuid: claims.sub,
|
||||||
message_type: payload.message_type,
|
message_type: payload.message_type,
|
||||||
content: payload.content,
|
content: payload.content,
|
||||||
sent_at: sent_at.format("%Y-%m-%d %H:%M:%S").to_string(),
|
sent_at: sent_at.format("%Y-%m-%d %H:%M:%S").to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user