diff --git a/crates/lavina-core/src/player.rs b/crates/lavina-core/src/player.rs index ad6e47d..9ffe831 100644 --- a/crates/lavina-core/src/player.rs +++ b/crates/lavina-core/src/player.rs @@ -18,7 +18,7 @@ use tracing::{Instrument, Span}; use crate::clustering::room::*; use crate::prelude::*; -use crate::room::{HistoryMessage, RoomHandle, RoomId, RoomInfo}; +use crate::room::{RoomHandle, RoomId, RoomInfo, StoredMessage}; use crate::table::{AnonTable, Key as AnonKey}; use crate::LavinaCore; @@ -112,7 +112,7 @@ impl PlayerConnection { } #[tracing::instrument(skip(self), name = "PlayerConnection::get_room_message_history")] - pub async fn get_room_message_history(&self, room_id: RoomId) -> Result<(Vec)> { + pub async fn get_room_message_history(&self, room_id: RoomId) -> Result<(Vec)> { let (promise, deferred) = oneshot(); let cmd = ClientCommand::GetRoomHistory { room_id, promise }; self.player_handle.send(ActorCommand::ClientCommand(cmd, self.connection_id.clone())).await; @@ -222,7 +222,7 @@ pub enum ClientCommand { }, GetRoomHistory { room_id: RoomId, - promise: Promise>, + promise: Promise>, }, } @@ -575,7 +575,7 @@ impl Player { } #[tracing::instrument(skip(self), name = "Player::retrieve_room_history")] - async fn get_room_history(&mut self, room_id: RoomId) -> Vec { + async fn get_room_history(&mut self, room_id: RoomId) -> Vec { let room = self.my_rooms.get(&room_id); if let Some(room) = room { match room { diff --git a/crates/lavina-core/src/repo/dialog.rs b/crates/lavina-core/src/repo/dialog.rs index 5d4c098..e228303 100644 --- a/crates/lavina-core/src/repo/dialog.rs +++ b/crates/lavina-core/src/repo/dialog.rs @@ -89,13 +89,3 @@ pub struct StoredDialog { pub participant_2: u32, pub message_count: u32, } - -#[derive(FromRow)] -pub struct StoredMessageWithAuthor { - pub room_id: u32, - pub id: u32, - pub content: String, - pub author_id: u32, - pub author_name: String, - pub created_at: DateTime, -} diff --git a/crates/lavina-core/src/repo/room.rs b/crates/lavina-core/src/repo/room.rs index 44d1328..81d0398 100644 --- a/crates/lavina-core/src/repo/room.rs +++ b/crates/lavina-core/src/repo/room.rs @@ -1,10 +1,9 @@ -use crate::repo::dialog::StoredMessageWithAuthor; use anyhow::{anyhow, Result}; use chrono::{DateTime, Utc}; use sqlx::FromRow; use crate::repo::Storage; -use crate::room::{HistoryMessage, RoomId, User}; +use crate::room::{RoomId, StoredMessage, StoredUser}; #[derive(FromRow)] pub struct StoredRoom { @@ -31,7 +30,7 @@ impl Storage { } #[tracing::instrument(skip(self), name = "Storage::retrieve_room_message_history")] - pub async fn get_room_message_history(&self, room_id: u32) -> Result> { + pub async fn get_room_message_history(&self, room_id: u32) -> Result> { let mut executor = self.conn.lock().await; let res = sqlx::query_as( " diff --git a/crates/lavina-core/src/room.rs b/crates/lavina-core/src/room.rs index 46704d0..ec542b9 100644 --- a/crates/lavina-core/src/room.rs +++ b/crates/lavina-core/src/room.rs @@ -160,7 +160,7 @@ impl RoomHandle { lock.broadcast_update(update, player_id).await; } - pub async fn get_message_history(&self, services: &LavinaCore) -> Vec { + pub async fn get_message_history(&self, services: &LavinaCore) -> Vec { return services.storage.get_room_message_history(self.0.read().await.storage_id).await.unwrap(); } @@ -287,24 +287,24 @@ pub struct RoomInfo { } #[derive(Debug)] -pub struct User { +pub struct StoredUser { pub id: u32, pub name: String, } #[derive(Debug)] -pub struct HistoryMessage { +pub struct StoredMessage { pub id: u32, - pub author: User, + pub author: StoredUser, pub content: String, pub created_at: DateTime, } -impl FromRow<'_, SqliteRow> for HistoryMessage { +impl FromRow<'_, SqliteRow> for StoredMessage { fn from_row(row: &SqliteRow) -> sqlx::Result { Ok(Self { id: row.try_get("id")?, - author: User { + author: StoredUser { id: row.try_get("author_id")?, name: row.try_get("author_name")?, },