mirror of
https://github.com/nostrlabs-io/notepush.git
synced 2025-06-16 03:48:10 +00:00
Fix empty cache entry state
There was an issue where an empty cache entry would get interpreted as a "no cache entry found" situation and cause notepush to always fetch a new mutelist Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@ -97,15 +97,23 @@ impl Cache {
|
|||||||
if let Some(entry) = self.mute_lists.get(pubkey) {
|
if let Some(entry) = self.mute_lists.get(pubkey) {
|
||||||
let entry = entry.clone(); // Clone the Arc to avoid borrowing issues
|
let entry = entry.clone(); // Clone the Arc to avoid borrowing issues
|
||||||
if !entry.is_expired(self.max_age) {
|
if !entry.is_expired(self.max_age) {
|
||||||
if let Some(event) = entry.event.clone() {
|
match &entry.event {
|
||||||
|
Some(event) => {
|
||||||
|
log::debug!("Cached mute list for pubkey {} was found", pubkey.to_hex());
|
||||||
return Ok(event.to_mute_list());
|
return Ok(event.to_mute_list());
|
||||||
}
|
}
|
||||||
|
None => {
|
||||||
|
log::debug!("Empty mute list cache entry for pubkey {}", pubkey.to_hex());
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log::debug!("Mute list for pubkey {} is expired, removing it from the cache", pubkey.to_hex());
|
log::debug!("Mute list for pubkey {} is expired, removing it from the cache", pubkey.to_hex());
|
||||||
self.mute_lists.remove(pubkey);
|
self.mute_lists.remove(pubkey);
|
||||||
self.remove_event_from_all_maps(&entry.event);
|
self.remove_event_from_all_maps(&entry.event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log::debug!("Mute list for pubkey {} not found on cache", pubkey.to_hex());
|
||||||
Err(CacheError::NotFound)
|
Err(CacheError::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user