Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add id to AudioBlockElement to fix missing media-id for audio assets on DCR rendered podcast pages #27686

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading