mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: ya pub-to 0 checks if any peer is able to receive the message (#2697)
Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
parent
01a13fd664
commit
37e8747c01
1 changed files with 14 additions and 4 deletions
|
|
@ -100,12 +100,22 @@ impl Client {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
match peers.get(&receiver).map(|p| p.able(kind)) {
|
match (receiver, peers.get(&receiver).map(|p| p.able(kind))) {
|
||||||
Some(true) => {}
|
// Send to all receivers
|
||||||
Some(false) => {
|
(Id(0), _) if peers.is_empty() => {
|
||||||
|
bail!("No receiver found. Check if any receivers are running.")
|
||||||
|
}
|
||||||
|
(Id(0), _) if peers.values().all(|p| !p.able(kind)) => {
|
||||||
|
bail!("No receiver has the ability to receive `{kind}` messages.")
|
||||||
|
}
|
||||||
|
(Id(0), _) => {}
|
||||||
|
|
||||||
|
// Send to a specific receiver
|
||||||
|
(_, Some(true)) => {}
|
||||||
|
(_, Some(false)) => {
|
||||||
bail!("Receiver `{receiver}` does not have the ability to receive `{kind}` messages.")
|
bail!("Receiver `{receiver}` does not have the ability to receive `{kind}` messages.")
|
||||||
}
|
}
|
||||||
None => bail!("Receiver `{receiver}` not found. Check if the receiver is running."),
|
(_, None) => bail!("Receiver `{receiver}` not found. Check if the receiver is running."),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue