Skip to content

Commit

Permalink
Only poll who if who is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm committed Sep 27, 2024
1 parent ce149b8 commit 7ff263c
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions data/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,31 +836,33 @@ impl Client {
if user.nickname() == self.nickname() {
self.chanmap.insert(channel.clone(), Channel::default());

if let Some(state) = self.chanmap.get_mut(channel) {
// Sends WHO to get away state on users.
if self.isupport.contains_key(&isupport::Kind::WHOX) {
let fields = if self.supports_account_notify {
"tcnfa"
// Sends WHO to get away state on users if WHO poll is enabled.
if self.config.who_poll_enabled {
if let Some(state) = self.chanmap.get_mut(channel) {
if self.isupport.contains_key(&isupport::Kind::WHOX) {
let fields = if self.supports_account_notify {
"tcnfa"
} else {
"tcnf"
};

let _ = self.handle.try_send(command!(
"WHO",
channel,
fields,
isupport::WHO_POLL_TOKEN.to_owned()
));

state.last_who = Some(WhoStatus::Requested(
Instant::now(),
Some(isupport::WHO_POLL_TOKEN),
));
} else {
"tcnf"
};

let _ = self.handle.try_send(command!(
"WHO",
channel,
fields,
isupport::WHO_POLL_TOKEN.to_owned()
));

state.last_who = Some(WhoStatus::Requested(
Instant::now(),
Some(isupport::WHO_POLL_TOKEN),
));
} else {
let _ = self.handle.try_send(command!("WHO", channel));
state.last_who = Some(WhoStatus::Requested(Instant::now(), None));
let _ = self.handle.try_send(command!("WHO", channel));
state.last_who = Some(WhoStatus::Requested(Instant::now(), None));
}
log::debug!("[{}] {channel} - WHO requested", self.server);
}
log::debug!("[{}] {channel} - WHO requested", self.server);
}

return Some(vec![Event::JoinedChannel(channel.clone())]);
Expand Down

0 comments on commit 7ff263c

Please sign in to comment.