fix(readarr): tolerate book payloads that omit the grabbed flag

This commit is contained in:
Dark-Alex-17 committed 2026-09-29 23:25:19 -06:00
1 parent 9128e68d0a
commit 642a5c0a87
2 files changed
+17

No files matched your search

+1
View File
@@ -280,6 +280,7 @@ pub struct Book {
pub ratings: Option<Ratings>, pub ratings: Option<Ratings>,
pub release_date: Option<DateTime<Utc>>, pub release_date: Option<DateTime<Utc>>,
pub statistics: Option<BookStatistics>, pub statistics: Option<BookStatistics>,
#[serde(default)]
pub grabbed: bool, pub grabbed: bool,
} }
+16
View File
@@ -939,6 +939,22 @@ mod tests {
assert_none!(&book.statistics); assert_none!(&book.statistics);
} }
#[test]
fn test_book_deserialization_defaults_grabbed_when_absent() {
let book_json = json!({
"id": 1,
"title": "The Name of the Wind",
"authorId": 3,
"foreignBookId": "test-foreign-book-id",
"monitored": true
});
let book: Book = serde_json::from_value(book_json).unwrap();
assert!(!book.grabbed);
assert!(book.monitored);
}
#[test] #[test]
fn test_edition_deserialization() { fn test_edition_deserialization() {
let edition_json = json!({ let edition_json = json!({