[irc] send 502 if not sender tries to change mode for other users

This commit is contained in:
JustTestingV 2023-09-06 21:06:05 +03:00
parent 377d9c32d2
commit ea0115aa29
2 changed files with 22 additions and 1 deletions

View File

@ -528,7 +528,17 @@ async fn handle_incoming_message(
.await?;
writer.flush().await?;
} else {
// TODO send 502 (not 401) if the user is not the sender
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?;
}
}
Recipient::Chan(_) => {

View File

@ -132,6 +132,10 @@ pub enum ServerMessageBody {
chan: Chan,
message: Str,
},
N502UsersDontMatch {
client: Str,
message: Str,
},
}
impl ServerMessageBody {
@ -301,6 +305,13 @@ 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(())
}