fix(sonarr): Pass the blocklist item ID alongside the DeleteBlocklistItem event when publishing to the networking channel

This commit is contained in:
2024-12-17 22:22:32 -07:00
parent 478b4ae3c0
commit 906e093152
7 changed files with 40 additions and 29 deletions
+5 -19
View File
@@ -42,7 +42,7 @@ pub enum SonarrEvent {
AddSeries(AddSeriesBody),
AddTag(String),
ClearBlocklist,
DeleteBlocklistItem(Option<i64>),
DeleteBlocklistItem(i64),
DeleteDownload(Option<i64>),
DeleteEpisodeFile(Option<i64>),
DeleteIndexer(Option<i64>),
@@ -459,30 +459,16 @@ impl<'a, 'b> Network<'a, 'b> {
.await
}
async fn delete_sonarr_blocklist_item(&mut self, blocklist_item_id: Option<i64>) -> Result<()> {
let event = SonarrEvent::DeleteBlocklistItem(None);
let id = if let Some(b_id) = blocklist_item_id {
b_id
} else {
self
.app
.lock()
.await
.data
.sonarr_data
.blocklist
.current_selection()
.id
};
info!("Deleting Sonarr blocklist item for item with id: {id}");
async fn delete_sonarr_blocklist_item(&mut self, blocklist_item_id: i64) -> Result<()> {
let event = SonarrEvent::DeleteBlocklistItem(blocklist_item_id);
info!("Deleting Sonarr blocklist item for item with id: {blocklist_item_id}");
let request_props = self
.request_props_from(
event,
RequestMethod::Delete,
None::<()>,
Some(format!("/{id}")),
Some(format!("/{blocklist_item_id}")),
None,
)
.await;
+3 -3
View File
@@ -281,7 +281,7 @@ mod test {
#[rstest]
#[case(SonarrEvent::ClearBlocklist, "/blocklist/bulk")]
#[case(SonarrEvent::DeleteBlocklistItem(None), "/blocklist")]
#[case(SonarrEvent::DeleteBlocklistItem(0), "/blocklist")]
#[case(SonarrEvent::HealthCheck, "/health")]
#[case(SonarrEvent::GetBlocklist, "/blocklist?page=1&pageSize=10000")]
#[case(SonarrEvent::GetDiskSpace, "/diskspace")]
@@ -540,7 +540,7 @@ mod test {
None,
None,
None,
SonarrEvent::DeleteBlocklistItem(None),
SonarrEvent::DeleteBlocklistItem(1),
Some("/1"),
None,
)
@@ -555,7 +555,7 @@ mod test {
let mut network = Network::new(&app_arc, CancellationToken::new(), Client::new());
assert!(network
.handle_sonarr_event(SonarrEvent::DeleteBlocklistItem(None))
.handle_sonarr_event(SonarrEvent::DeleteBlocklistItem(1))
.await
.is_ok());