diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-14 13:47:11 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-14 13:47:11 +0000 |
| commit | a1d67c50c8ebc5395b069e30b60d66e0c7de5a5a (patch) | |
| tree | 0895e4cfab98e7c7bbf45ddbac2e7af2c51935e6 /src/sub_commands/send.rs | |
| parent | fed60687b2438b6bd19ee8f5c854ddc53cad0c9b (diff) | |
feat: send to default relays, blast repo event
improve the distribution of events by sending to default relays
in addition to user and repo relays. for better discoverability of
repo events, this is also blasted.
a temporary fix to blast everything was removed.
the less reliable purplepages.es relay is moved to
more_fallback_relays that currently isn't used
Diffstat (limited to 'src/sub_commands/send.rs')
| -rw-r--r-- | src/sub_commands/send.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 2c1dec8..b8cb271 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -183,7 +183,23 @@ pub async fn send_events( | |||
| 183 | repo_read_relays: Vec<String>, | 183 | repo_read_relays: Vec<String>, |
| 184 | animate: bool, | 184 | animate: bool, |
| 185 | ) -> Result<()> { | 185 | ) -> Result<()> { |
| 186 | let (_, _, _, all) = unique_and_duplicate_all(&my_write_relays, &repo_read_relays); | 186 | let (_, _, _, mut all) = unique_and_duplicate_all(&my_write_relays, &repo_read_relays); |
| 187 | |||
| 188 | let mut fallback = client.get_fallback_relays().clone(); | ||
| 189 | |||
| 190 | // blast repo events | ||
| 191 | if events.iter().any(|e| e.kind().as_u64().eq(&REPO_REF_KIND)) { | ||
| 192 | for r in client.get_blaster_relays() { | ||
| 193 | fallback.push(r.to_string()); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | // then remaining fallback list | ||
| 198 | for r in &fallback { | ||
| 199 | if !all.iter().any(|r2| r2.eq(&r)) { | ||
| 200 | all.push(r); | ||
| 201 | } | ||
| 202 | } | ||
| 187 | 203 | ||
| 188 | let m = MultiProgress::new(); | 204 | let m = MultiProgress::new(); |
| 189 | let pb_style = ProgressStyle::with_template(if animate { | 205 | let pb_style = ProgressStyle::with_template(if animate { |
| @@ -215,7 +231,7 @@ pub async fn send_events( | |||
| 215 | 231 | ||
| 216 | join_all(all.iter().map(|&relay| async { | 232 | join_all(all.iter().map(|&relay| async { |
| 217 | let details = format!( | 233 | let details = format!( |
| 218 | "{}{} {}", | 234 | "{}{}{} {}", |
| 219 | if my_write_relays.iter().any(|r| relay.eq(r)) { | 235 | if my_write_relays.iter().any(|r| relay.eq(r)) { |
| 220 | " [my-relay]" | 236 | " [my-relay]" |
| 221 | } else { | 237 | } else { |
| @@ -226,6 +242,11 @@ pub async fn send_events( | |||
| 226 | } else { | 242 | } else { |
| 227 | "" | 243 | "" |
| 228 | }, | 244 | }, |
| 245 | if fallback.iter().any(|r| relay.eq(r)) { | ||
| 246 | " [default]" | ||
| 247 | } else { | ||
| 248 | "" | ||
| 249 | }, | ||
| 229 | *relay, | 250 | *relay, |
| 230 | ); | 251 | ); |
| 231 | let pb = m.add( | 252 | let pb = m.add( |