Skip to content

Commit

Permalink
Make another ddex delivery work (different URL) (#8161)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoilie authored Apr 19, 2024
1 parent a50c773 commit d66d393
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/schemas/upload/uploadFormSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const DDEXResourceContributor = z
.object({
name: z.string(),
roles: z.array(z.string()),
sequence_number: z.number().positive()
sequence_number: z.optional(z.number())
})
.strict()

Expand Down
7 changes: 7 additions & 0 deletions packages/ddex/ingester/parser/ern38x.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ func buildAlbumMetadata(release *common.Release, mainRelease *common.ParsedRelea
return
}

// Use mainRelease's genre for all tracks if a track is missing a genre
for i := range tracks {
if tracks[i].Genre == "" {
tracks[i].Genre = mainRelease.Genre
}
}

// Album is required to have a cover art image
if mainRelease.Resources.Images == nil || len(mainRelease.Resources.Images) == 0 || mainRelease.Resources.Images[0].URL == "" {
*errs = append(*errs, fmt.Errorf("missing cover art image for release %s", mainRelease.ReleaseRef))
Expand Down
7 changes: 7 additions & 0 deletions packages/ddex/ingester/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ func (p *Parser) parseBatch(batch *common.UnprocessedBatch, deliveryRemotePath s

// Validate the URL without the prefix "/"
releaseURL := strings.TrimPrefix(safeInnerText(messageInBatch.SelectElement("URL")), "/")

// Special case for Fuga deliveries with a different URL format
if strings.Contains(releaseURL, "ddex-prod-fuga-raw") {
releaseURL = strings.SplitAfter(releaseURL, "ddex-prod-fuga-raw//")[1]
releaseURL = fmt.Sprintf("%s/%s", strings.Split(targetRelease.XmlFilePath, "/")[0], releaseURL)
}

if releaseURL != targetRelease.XmlFilePath {
err := fmt.Errorf("URL '%s' does not match expected value: '%s'", releaseURL, targetRelease.XmlFilePath)
batch.ValidationErrors = append(batch.ValidationErrors, err.Error())
Expand Down
3 changes: 1 addition & 2 deletions packages/ddex/publisher/src/models/publishedReleases.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import mongoose from 'mongoose'
import { releaseSchema } from './pendingReleases'

// DDEX releases that have been published
const publishedReleasesSchema = new mongoose.Schema({
Expand All @@ -8,7 +7,7 @@ const publishedReleasesSchema = new mongoose.Schema({
entity_id: String,
blockhash: String,
blocknumber: Number,
release: releaseSchema,
release: { type: mongoose.Schema.Types.Mixed, default: null },
created_at: Date,
})

Expand Down
2 changes: 1 addition & 1 deletion packages/libs/src/sdk/types/DDEX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const DDEXResourceContributor = z
.object({
name: z.string(),
roles: z.array(z.string()),
sequence_number: z.number().positive()
sequence_number: z.optional(z.number())
})
.strict()

Expand Down

0 comments on commit d66d393

Please sign in to comment.