diff --git a/crates/lavina-core/src/player.rs b/crates/lavina-core/src/player.rs index f14da4b..8c89b86 100644 --- a/crates/lavina-core/src/player.rs +++ b/crates/lavina-core/src/player.rs @@ -126,9 +126,9 @@ impl PlayerConnection { Ok(deferred.await?) } - /// Handler in [Player::check_user_existance]. - #[tracing::instrument(skip(self), name = "PlayerConnection::send_dialog_message")] - pub async fn check_user_existance(&self, recipient: PlayerId) -> Result { + /// Handler in [Player::check_user_existence]. + #[tracing::instrument(skip(self), name = "PlayerConnection::check_user_existence")] + pub async fn check_user_existence(&self, recipient: PlayerId) -> Result { let (promise, deferred) = oneshot(); let cmd = ClientCommand::GetInfo { recipient, promise }; self.player_handle.send(ActorCommand::ClientCommand(cmd, self.connection_id.clone())).await; @@ -520,7 +520,7 @@ impl Player { let _ = promise.send(()); } ClientCommand::GetInfo { recipient, promise } => { - let result = self.check_user_existance(recipient).await; + let result = self.check_user_existence(recipient).await; let _ = promise.send(result); } } @@ -619,9 +619,9 @@ impl Player { self.broadcast_update(update, connection_id).await; } - #[tracing::instrument(skip(self), name = "Player::check_user_existance")] - async fn check_user_existance(&self, recipient: PlayerId) -> GetInfoResult { - if self.storage.check_user_existance(recipient.as_inner().as_ref()).await.unwrap() { + #[tracing::instrument(skip(self), name = "Player::check_user_existence")] + async fn check_user_existence(&self, recipient: PlayerId) -> GetInfoResult { + if self.storage.check_user_existence(recipient.as_inner().as_ref()).await.unwrap() { GetInfoResult::UserExists } else { GetInfoResult::UserDoesntExist diff --git a/crates/lavina-core/src/repo/mod.rs b/crates/lavina-core/src/repo/mod.rs index 49a31e8..4c29651 100644 --- a/crates/lavina-core/src/repo/mod.rs +++ b/crates/lavina-core/src/repo/mod.rs @@ -56,8 +56,8 @@ impl Storage { Ok(res) } - #[tracing::instrument(skip(self), name = "Storage::check_user_existance")] - pub async fn check_user_existance(&self, username: &str) -> Result { + #[tracing::instrument(skip(self), name = "Storage::check_user_existence")] + pub async fn check_user_existence(&self, username: &str) -> Result { let mut executor = self.conn.lock().await; let result: Option<(String,)> = sqlx::query_as("select name from users where name = ?;") .bind(username) diff --git a/crates/projection-irc/src/whois.rs b/crates/projection-irc/src/whois.rs index ae741ab..f48b90f 100644 --- a/crates/projection-irc/src/whois.rs +++ b/crates/projection-irc/src/whois.rs @@ -46,7 +46,7 @@ async fn handle_nick_target(nick: Str, body: IrcConnection<'_, impl AsyncWrite + } = body; if let GetInfoResult::UserDoesntExist = - player_connection.check_user_existance(PlayerId::from(nick.clone())?).await? + player_connection.check_user_existence(PlayerId::from(nick.clone())?).await? { IrcResponseMessage::empty_tags( Some(server_name.clone()), diff --git a/crates/proto-irc/src/commands/whois/response.rs b/crates/proto-irc/src/commands/whois/response.rs index 9f3443b..506ebf4 100644 --- a/crates/proto-irc/src/commands/whois/response.rs +++ b/crates/proto-irc/src/commands/whois/response.rs @@ -1,143 +1,7 @@ -use std::{net::IpAddr, time::SystemTime}; - use tokio::io::{AsyncWrite, AsyncWriteExt}; -use crate::{prelude::Str, response::WriteResponse, Chan}; +use crate::{prelude::Str, response::WriteResponse}; -/// " :has client certificate fingerprint " -/// Clients MUST only be sent this numeric if they are either using the WHOIS command on themselves -/// or they are an operator. -struct RplWhoisCertfp276 { - client: Str, - nick: Str, - fingerprint: Str, -} - -/// " :has identified for this nick" -struct RplWhoisRegNick307 { - client: Str, - nick: Str, -} -/// " * :" -pub struct RplWhoIsUser311 { - client: Str, - /// unique name - nick: Str, - /// username not unique - username: Option, - /// server name - host: Str, - realname: Str, -} - -impl RplWhoIsUser311 { - pub fn new(client: Str, nick: Str, username: Option, host: Str, realname: Str) -> Self { - RplWhoIsUser311 { - client, - nick, - username, - host, - realname, - } - } -} -/// " :" -struct RplWhoisServer312 { - client: Str, - nick: Str, - server: Str, - /// description of the server - server_info: String, -} - -/// " :is an IRC operator" -struct RplWhoisOperator313 { - client: Str, - nick: Str, -} - -/// Sent as a reply to the WHOIS command, this numeric indicates how long the client with the nickname has been idle. -/// is the number of seconds since the client has been active. -/// Servers generally denote specific commands (for instance, perhaps JOIN, PRIVMSG, NOTICE, etc) as updating the ‘idle time’, -/// and calculate this off when the idle time was last updated. -/// is a unix timestamp representing when the user joined the network. The text used in the last param of this message may vary. -struct RplWhoisIdle317 { - client: Str, - nick: Str, - /// number of seconds client been active - secs: f32, - sigon: SystemTime, -} - -struct PrefixedChan { - prefix: Option, - chan: Chan, -} - -struct RplWhoisChannels319 { - client: Str, - nick: Str, - highest_membership: PrefixedChan, - /// The last parameter of this numeric is a list of [prefix] pairs, - /// delimited by a SPACE character (' ', 0x20). - /// RPL_WHOISCHANNELS can be sent multiple times in the same whois reply, - /// if the target is on too many channels to fit in a single message. - chanels: [PrefixedChan; 20], -} - -/// is used for extra human-readable information on the client with nickname . -/// This should only be used for non-essential information, -/// that does not need to be machine-readable or understood by client software. -struct RplWhoisSpecial320 { - client: Str, - nick: Str, -} -/// " :is logged in as" -struct RplWhoisAccount330 { - client: Str, - nick: Str, - account: Str, -} - -/// " :is actually ..." -/// " :Is actually using host" -/// " @ :Is actually using host" -struct RplWhoisActually338 { - client: Str, - nick: Str, - username: Str, - /// CANNOT start with a colon (':', 0x3A) - host: Str, - ip: IpAddr, -} - -/// " :is connecting from *@localhost 127.0.0.1" -struct RplWhoisHost378 { - client: Str, - nick: Str, - host: Str, -} - -struct Mode(Str); -/// " :is using modes +ailosw" -struct RplWhoisModes379 { - client: Str, - nick: Str, - modes: Vec, -} - -/// " :is using a secure connection" -struct RplWhoisSecure671 { - client: Str, - nick: Str, - is_secure: bool, -} -/// " :" -struct RplAway301 { - client: Str, - nick: Str, - default_away_message: Str, -} pub struct RplEndOfWhois318 { client: Str, nick: Str, @@ -147,30 +11,6 @@ impl RplEndOfWhois318 { RplEndOfWhois318 { client, nick } } } - -impl WriteResponse for RplWhoIsUser311 { - async fn write_response(&self, writer: &mut (impl AsyncWrite + Unpin)) -> std::io::Result<()> { - writer.write_all(b"311 ").await?; - writer.write_all(self.client.as_bytes()).await?; - writer.write_all(b" ").await?; - writer.write_all(self.nick.as_bytes()).await?; - if let Some(username) = &self.username { - writer.write_all(b" ").await?; - writer.write_all(username.as_bytes()).await?; - } - writer.write_all(b" ").await?; - writer.write_all(self.host.as_bytes()).await?; - writer.write_all(b" ").await?; - writer.write_all("*".as_bytes()).await?; - writer.write_all(b" ").await?; - writer.write_all(b" :").await?; - //todo no entity in db that represents whole irc user entity - writer.write_all("".as_bytes()).await?; - - Ok(()) - } -} - impl WriteResponse for RplEndOfWhois318 { async fn write_response(&self, writer: &mut (impl AsyncWrite + Unpin)) -> std::io::Result<()> { writer.write_all(b"318 ").await?;