|
1 | 1 | use crate::whitenoise::accounts::Account; |
2 | 2 | use crate::whitenoise::error::{Result, WhitenoiseError}; |
3 | 3 | use crate::whitenoise::Whitenoise; |
| 4 | +use crate::RelayType; |
4 | 5 | use nostr_mls::prelude::*; |
5 | 6 | use std::time::Duration; |
6 | 7 |
|
@@ -46,11 +47,7 @@ impl Whitenoise { |
46 | 47 |
|
47 | 48 | for pk in member_pubkeys.iter() { |
48 | 49 | let contact = self.load_contact(pk).await?; |
49 | | - let relays_to_use = if contact.key_package_relays.is_empty() { |
50 | | - Account::default_relays() |
51 | | - } else { |
52 | | - contact.key_package_relays.clone() |
53 | | - }; |
| 50 | + let relays_to_use = contact.get_relays_of_type(RelayType::KeyPackage); |
54 | 51 | let some_event = self |
55 | 52 | .fetch_key_package_event_from(relays_to_use, *pk) |
56 | 53 | .await?; |
@@ -121,11 +118,7 @@ impl Whitenoise { |
121 | 118 | // Create a timestamp 1 month in the future |
122 | 119 | use std::ops::Add; |
123 | 120 | let one_month_future = Timestamp::now().add(30 * 24 * 60 * 60); |
124 | | - let relays_to_use = if contact.inbox_relays.is_empty() { |
125 | | - Account::default_relays() |
126 | | - } else { |
127 | | - contact.inbox_relays.clone() |
128 | | - }; |
| 121 | + let relays_to_use = contact.get_relays_of_type(RelayType::Inbox); |
129 | 122 |
|
130 | 123 | self.nostr |
131 | 124 | .publish_gift_wrap_with_signer( |
@@ -255,11 +248,7 @@ impl Whitenoise { |
255 | 248 | // Fetch key packages for all members |
256 | 249 | for pk in members.iter() { |
257 | 250 | let contact = self.load_contact(pk).await?; |
258 | | - let relays_to_use = if contact.key_package_relays.is_empty() { |
259 | | - Account::default_relays() |
260 | | - } else { |
261 | | - contact.key_package_relays.clone() |
262 | | - }; |
| 251 | + let relays_to_use = contact.get_relays_of_type(RelayType::KeyPackage); |
263 | 252 | let some_event = self |
264 | 253 | .fetch_key_package_event_from(relays_to_use, *pk) |
265 | 254 | .await?; |
@@ -357,11 +346,7 @@ impl Whitenoise { |
357 | 346 | let one_month_future = Timestamp::now() + Duration::from_secs(30 * 24 * 60 * 60); |
358 | 347 |
|
359 | 348 | // Use fallback relays if contact has no inbox relays configured |
360 | | - let relays_to_use = if contact.inbox_relays.is_empty() { |
361 | | - Account::default_relays() |
362 | | - } else { |
363 | | - contact.inbox_relays |
364 | | - }; |
| 349 | + let relays_to_use = contact.get_relays_of_type(RelayType::Inbox); |
365 | 350 |
|
366 | 351 | self.nostr |
367 | 352 | .publish_gift_wrap_with_signer( |
|
0 commit comments