mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01: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)) {
|
||||
Some(true) => {}
|
||||
Some(false) => {
|
||||
match (receiver, peers.get(&receiver).map(|p| p.able(kind))) {
|
||||
// Send to all receivers
|
||||
(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.")
|
||||
}
|
||||
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(())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue