Skip to content

Commit

Permalink
Fix Book/Podcast updateFromRequest to support null values in string f…
Browse files Browse the repository at this point in the history
…ields #3938
  • Loading branch information
advplyr committed Feb 5, 2025
1 parent 0cf7a6a commit 24d6e39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/models/Book.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class Book extends Model {
if (payload.metadata) {
const metadataStringKeys = ['title', 'subtitle', 'publishedYear', 'publishedDate', 'publisher', 'description', 'isbn', 'asin', 'language']
metadataStringKeys.forEach((key) => {
if (typeof payload.metadata[key] === 'string' && this[key] !== payload.metadata[key]) {
if ((typeof payload.metadata[key] === 'string' || payload.metadata[key] === null) && this[key] !== payload.metadata[key]) {
this[key] = payload.metadata[key] || null

if (key === 'title') {
Expand Down
5 changes: 3 additions & 2 deletions server/models/Podcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ class Podcast extends Model {
} else if (key === 'itunesPageUrl') {
newKey = 'itunesPageURL'
}
if (typeof payload.metadata[key] === 'string' && payload.metadata[key] !== this[newKey]) {
this[newKey] = payload.metadata[key]
if ((typeof payload.metadata[key] === 'string' || payload.metadata[key] === null) && payload.metadata[key] !== this[newKey]) {
this[newKey] = payload.metadata[key] || null

if (key === 'title') {
this.titleIgnorePrefix = getTitleIgnorePrefix(this.title)
}
Expand Down

0 comments on commit 24d6e39

Please sign in to comment.