Skip to content

Commit

Permalink
Add id to AudioBlockElement to fix missing media-id for podcast audio…
Browse files Browse the repository at this point in the history
… assets
  • Loading branch information
arelra committed Dec 23, 2024
1 parent 2a8e447 commit 40cde4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions common/app/model/dotcomrendering/DotcomRenderingDataModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import conf.Configuration
import crosswords.CrosswordPageWithContent
import experiments.ActiveExperiments
import model.dotcomrendering.DotcomRenderingUtils._
import model.dotcomrendering.pageElements.{ImageBlockElement, PageElement, Role, TextCleaner}
import model.dotcomrendering.pageElements.{AudioBlockElement, ImageBlockElement, PageElement, Role, TextCleaner}
import model.liveblog.BlockAttributes
import model.{
ArticleDateTimes,
Expand Down Expand Up @@ -544,12 +544,24 @@ object DotcomRenderingDataModel {
)
}

val mainMediaElements =
mainBlock
val mainMediaElements = {
val pageElements = mainBlock
.map(toDCRBlock(isMainBlock = true))
.toList
.flatMap(_.elements)

page.metadata.contentType match {
case Some(DotcomContentType.Audio) =>
pageElements
.map {
case AudioBlockElement(assets, _) =>
AudioBlockElement(assets, Option(content.elements.mainAudio.head.properties.id))
case pageElement => pageElement
}
case _ => pageElements
}
}

val bodyBlocksDCR =
bodyBlocks
.filter(_.published || pageType.isPreview) // TODO lift?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object AudioAtomBlockElement {

// We are currently using AudioBlockElement as a catch all for audio errors, skipping the first definition
// See comment: 2e5ac4fd-e7f1-4c04-bdcd-ceadd2dc5d4c
case class AudioBlockElement(assets: Seq[AudioAsset]) extends PageElement
case class AudioBlockElement(assets: Seq[AudioAsset], id: Option[String] = None) extends PageElement
object AudioBlockElement {
implicit val AudioBlockElementWrites: Writes[AudioBlockElement] = Json.writes[AudioBlockElement]
}
Expand Down

0 comments on commit 40cde4d

Please sign in to comment.