diff --git a/applications/app/services/dotcomrendering/MediaPicker.scala b/applications/app/services/dotcomrendering/MediaPicker.scala index 29cdfc7a52d..3ed2133af06 100644 --- a/applications/app/services/dotcomrendering/MediaPicker.scala +++ b/applications/app/services/dotcomrendering/MediaPicker.scala @@ -5,28 +5,24 @@ import model.Cors.RichRequestHeader import model.{MediaPage, Video, Audio} import play.api.mvc.RequestHeader import utils.DotcomponentsLogger -import navigation.NavLinks.media -import experiments.ActiveExperiments -import conf.switches.Switches.DCRVideoPages +import conf.switches.Switches.{DCRAudioPages, DCRVideoPages} object MediaPicker extends GuLogging { /** Add to this function any logic for including/excluding an audio/video article from being rendered with DCR - * - * Currently defaulting to false until we implement in DCR */ - private def dcrCouldRender(mediaPage: MediaPage): Boolean = { + private def dcrShouldRender(mediaPage: MediaPage): Boolean = { mediaPage.media match { - case Video(content, source, mediaAtom) => true - case Audio(content) => false + case Audio(content) => DCRAudioPages.isSwitchedOn + case Video(content, source, mediaAtom) => DCRVideoPages.isSwitchedOn case _ => false } } private def dcrLogFlags(mediaPage: MediaPage): Map[String, String] = { Map( - ("isVideo", mediaPage.media.isInstanceOf[Video].toString()), ("isAudio", mediaPage.media.isInstanceOf[Audio].toString()), + ("isVideo", mediaPage.media.isInstanceOf[Video].toString()), ) } @@ -35,14 +31,12 @@ object MediaPicker extends GuLogging { )(implicit request: RequestHeader, ): RenderType = { - - val dcrCanRender = dcrCouldRender(mediaPage) val flags = dcrLogFlags(mediaPage) val tier = { if (request.forceDCROff) LocalRender else if (request.forceDCR) RemoteRender - else if (dcrCanRender && DCRVideoPages.isSwitchedOn) RemoteRender + else if (dcrShouldRender(mediaPage)) RemoteRender else LocalRender } diff --git a/common/app/conf/switches/FeatureSwitches.scala b/common/app/conf/switches/FeatureSwitches.scala index 169593af64c..2731ce6eb77 100644 --- a/common/app/conf/switches/FeatureSwitches.scala +++ b/common/app/conf/switches/FeatureSwitches.scala @@ -483,6 +483,16 @@ trait FeatureSwitches { exposeClientSide = true, ) + val DCRAudioPages = Switch( + SwitchGroup.Feature, + "dcr-audio-pages", + "If this switch is on, we will render audio pages with DCR", + owners = Seq(Owner.withEmail("dotcom.platform@theguardian.com"), Owner.withEmail("devx.e2e@theguardian.com")), + safeState = Off, + sellByDate = never, + exposeClientSide = false, + ) + val DCRVideoPages = Switch( SwitchGroup.Feature, "dcr-video-pages",