forked from lavina/lavina
[irc] send 502 if not sender tries to change mode for other users
This commit is contained in:
parent
fd6aeeda8a
commit
c3d0370120
|
@ -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(_) => {
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue