From b68b1cc04b69615dc4000aeeb64c7410e872b370 Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Tue, 21 May 2024 12:14:33 +0100 Subject: [PATCH] Remove affiliates cutoff date logic --- .../views/fragments/galleryBody.scala.html | 1 - applications/app/views/package.scala | 1 - article/app/views/package.scala | 1 - .../DotcomRenderingUtils.scala | 1 - common/app/views/support/HtmlCleaner.scala | 13 ++---------- .../cleaner/AffiliateLinksCleanerTest.scala | 21 ------------------- 6 files changed, 2 insertions(+), 36 deletions(-) diff --git a/applications/app/views/fragments/galleryBody.scala.html b/applications/app/views/fragments/galleryBody.scala.html index bc58cc8a5a3f..164ba2c137c9 100644 --- a/applications/app/views/fragments/galleryBody.scala.html +++ b/applications/app/views/fragments/galleryBody.scala.html @@ -32,7 +32,6 @@ defaultOffTags = Configuration.affiliateLinks.defaultOffTags, alwaysOffTags = Configuration.affiliateLinks.alwaysOffTags, tagPaths = page.gallery.content.tags.tags.map(_.id), - firstPublishedDate = page.gallery.content.fields.firstPublicationDate, ) ) diff --git a/applications/app/views/package.scala b/applications/app/views/package.scala index 7b554497dc43..488bcbe87080 100644 --- a/applications/app/views/package.scala +++ b/applications/app/views/package.scala @@ -46,7 +46,6 @@ object GalleryCaptionCleaners { page.gallery.content.fields.showAffiliateLinks, appendDisclaimer = Some(isFirstRow && page.item.lightbox.containsAffiliateableLinks), tags = page.gallery.content.tags.tags.map(_.id), - page.gallery.content.fields.firstPublicationDate, ), ) diff --git a/article/app/views/package.scala b/article/app/views/package.scala index 05d1f6ed5114..ee2714b108bf 100644 --- a/article/app/views/package.scala +++ b/article/app/views/package.scala @@ -83,7 +83,6 @@ object BodyProcessor { sectionId = article.content.metadata.sectionId, showAffiliateLinks = article.content.fields.showAffiliateLinks, tags = article.content.tags.tags.map(_.id), - publishedDate = article.content.fields.firstPublicationDate, ), ) ++ ListIf(true)(VideoEmbedCleaner(article)) diff --git a/common/app/model/dotcomrendering/DotcomRenderingUtils.scala b/common/app/model/dotcomrendering/DotcomRenderingUtils.scala index ebc6170089ba..a185afba9796 100644 --- a/common/app/model/dotcomrendering/DotcomRenderingUtils.scala +++ b/common/app/model/dotcomrendering/DotcomRenderingUtils.scala @@ -264,7 +264,6 @@ object DotcomRenderingUtils { defaultOffTags = Configuration.affiliateLinks.defaultOffTags, alwaysOffTags = Configuration.affiliateLinks.alwaysOffTags, tagPaths = content.content.tags.tags.map(_.id), - firstPublishedDate = content.content.fields.firstPublicationDate, ) } else false } else false diff --git a/common/app/views/support/HtmlCleaner.scala b/common/app/views/support/HtmlCleaner.scala index 61185dae588a..25819ffec37e 100644 --- a/common/app/views/support/HtmlCleaner.scala +++ b/common/app/views/support/HtmlCleaner.scala @@ -871,7 +871,6 @@ case class AffiliateLinksCleaner( showAffiliateLinks: Option[Boolean], appendDisclaimer: Option[Boolean] = None, tags: List[String], - publishedDate: Option[DateTime], ) extends HtmlCleaner with GuLogging { @@ -885,7 +884,6 @@ case class AffiliateLinksCleaner( defaultOffTags, alwaysOffTags, tags, - publishedDate, ) ) { AffiliateLinksCleaner.replaceLinksInHtml(document, pageUrl, skimlinksId) @@ -940,17 +938,10 @@ object AffiliateLinksCleaner { defaultOffTags: Set[String], alwaysOffTags: Set[String], tagPaths: List[String], - firstPublishedDate: Option[DateTime], ): Boolean = { - val publishedCutOffDate = new DateTime(2020, 8, 14, 0, 0) - // Never include affiliate links if it is tagged with an always off tag, or if it was published before our cut off date. - // The cut off date is temporary while we are working on improving the compliance of affiliate links. - if ( - !contentHasAlwaysOffTag(tagPaths, alwaysOffTags) && firstPublishedDate.exists( - _.isBefore(publishedCutOffDate), - ) - ) { + // Never include affiliate links if it is tagged with an always off tag + if (!contentHasAlwaysOffTag(tagPaths, alwaysOffTags)) { if (showAffiliateLinks.isDefined) { showAffiliateLinks.contains(true) } else { diff --git a/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala b/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala index 82967ac52d9c..d6ad0ee20de3 100644 --- a/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala +++ b/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala @@ -17,8 +17,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { "shouldAddAffiliateLinks" should "correctly determine when to add affiliate links" in { val supportedSections = Set("film", "books", "fashion") - val oldPublishedDate = Some(new DateTime(2020, 8, 13, 0, 0)) - val newPublishedDate = Some(new DateTime(2020, 8, 15, 0, 0)) shouldAddAffiliateLinks( switchedOn = false, @@ -28,7 +26,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, Set.empty, List.empty, - oldPublishedDate, ) should be(false) shouldAddAffiliateLinks( switchedOn = true, @@ -38,7 +35,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, Set.empty, List.empty, - oldPublishedDate, ) should be(true) shouldAddAffiliateLinks( switchedOn = true, @@ -48,7 +44,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, Set.empty, List.empty, - oldPublishedDate, ) should be(false) shouldAddAffiliateLinks( switchedOn = true, @@ -58,7 +53,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, Set.empty, List.empty, - oldPublishedDate, ) should be(true) shouldAddAffiliateLinks( switchedOn = true, @@ -68,7 +62,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set("bereavement"), Set.empty, List("bereavement"), - oldPublishedDate, ) should be(false) shouldAddAffiliateLinks( switchedOn = true, @@ -78,7 +71,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set("bereavement"), Set.empty, List("tech"), - oldPublishedDate, ) should be(false) shouldAddAffiliateLinks( switchedOn = true, @@ -88,7 +80,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set("bereavement"), Set.empty, List("tech"), - oldPublishedDate, ) should be(true) shouldAddAffiliateLinks( switchedOn = true, @@ -98,7 +89,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, Set("bereavement"), List("bereavement"), - oldPublishedDate, ) should be(false) shouldAddAffiliateLinks( switchedOn = true, @@ -108,17 +98,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, Set("bereavement"), List("tech"), - oldPublishedDate, - ) should be(true) - shouldAddAffiliateLinks( - switchedOn = true, - "film", - None, - supportedSections, - Set.empty, - Set.empty, - List.empty, - newPublishedDate, ) should be(true) } }