Compare commits

..

No commits in common. "53f218c58fafa70d11bc9dc2411fb7396bca1ab7" and "43ea27b6553a8eb2cf009d7c42ca3caeba08ea5c" have entirely different histories.

4 changed files with 4 additions and 29 deletions

View File

@ -78,7 +78,7 @@ impl Storage {
pub async fn insert_message(&mut self, room_id: u32, id: u32, content: &str) -> Result<()> {
let mut executor = self.conn.lock().await;
sqlx::query(
let (_,): (u32,) = sqlx::query_as(
"insert into messages(room_id, id, content)
values (?, ?, ?);
update rooms set message_count = message_count + 1 where id = ?;",
@ -87,7 +87,7 @@ impl Storage {
.bind(id)
.bind(content)
.bind(room_id)
.execute(&mut *executor)
.fetch_one(&mut *executor)
.await?;
Ok(())

View File

@ -140,10 +140,7 @@ impl RoomHandle {
pub async fn send_message(&self, player_id: PlayerId, body: Str) {
let mut lock = self.0.write().await;
let res = lock.send_message(player_id, body).await;
if let Err(err) = res {
log::warn!("Failed to send message: {err:?}");
}
lock.send_message(player_id, body).await;
}
pub async fn get_room_info(&self) -> RoomInfo {
@ -203,7 +200,6 @@ impl Room {
}
async fn broadcast_update(&self, update: Updates, except: &PlayerId) {
tracing::debug!("Broadcasting an update to {} subs", self.subscriptions.len());
for (player_id, sub) in &self.subscriptions {
if player_id == except {
continue;

View File

@ -528,17 +528,7 @@ async fn handle_incoming_message(
.await?;
writer.flush().await?;
} else {
ServerMessage {
tags: vec![],
sender: Some(config.server_name.clone()),
body: ServerMessageBody::N502UsersDontMatch {
client: user.nickname.clone(),
message: "Cant change mode for other users".into(),
},
}
.write_async(writer)
.await?;
writer.flush().await?;
// TODO send 502 (not 401) if the user is not the sender
}
}
Recipient::Chan(_) => {

View File

@ -132,10 +132,6 @@ pub enum ServerMessageBody {
chan: Chan,
message: Str,
},
N502UsersDontMatch {
client: Str,
message: Str,
},
}
impl ServerMessageBody {
@ -305,13 +301,6 @@ impl ServerMessageBody {
writer.write_all(b" :").await?;
writer.write_all(message.as_bytes()).await?;
}
ServerMessageBody::N502UsersDontMatch { client, message } => {
writer.write_all(b"502 ").await?;
writer.write_all(client.as_bytes()).await?;
writer.write_all(b" ").await?;
writer.write_all(b" :").await?;
writer.write_all(message.as_bytes()).await?;
}
}
Ok(())
}