diff --git a/article/app/AppLoader.scala b/article/app/AppLoader.scala index 415624079cb4..bd22fe2d6062 100644 --- a/article/app/AppLoader.scala +++ b/article/app/AppLoader.scala @@ -13,8 +13,8 @@ import contentapi.{CapiHttpClient, ContentApiClient, HttpClient} import controllers.{ArticleControllers, HealthCheck} import dev.{DevAssetsController, DevParametersHttpRequestHandler} import http.{CommonFilters, CorsHttpErrorHandler} -import jobs.{MessageUsLifecycle, StoreNavigationLifecycleComponent, TopicLifecycle} -import model.{ApplicationIdentity, MessageUsConfigData, TopicsApiResponse} +import jobs.{StoreNavigationLifecycleComponent, TopicLifecycle} +import model.{ApplicationIdentity, TopicsApiResponse} import play.api.ApplicationLoader.Context import play.api.BuiltInComponentsFromContext import play.api.http.{HttpErrorHandler, HttpRequestHandler} @@ -24,14 +24,7 @@ import router.Routes import services.fronts.FrontJsonFapiLive import services.newsletters.{NewsletterApi, NewsletterSignupAgent, NewsletterSignupLifecycle} import services.ophan.SurgingContentAgentLifecycle -import services.{ - MessageUsService, - NewspaperBooksAndSectionsAutoRefresh, - OphanApi, - S3Client, - S3ClientImpl, - SkimLinksCacheLifeCycle, -} +import services.{NewspaperBooksAndSectionsAutoRefresh, OphanApi, S3Client, S3ClientImpl, SkimLinksCacheLifeCycle} import topics.TopicService class AppLoader extends FrontendApplicationLoader { @@ -44,12 +37,7 @@ trait TopicServices { lazy val topicService = wire[TopicService] } -trait MessageUsServices { - lazy val messageUsS3Client: S3Client[MessageUsConfigData] = new S3ClientImpl(Configuration.aws.messageUsStoreBucket) - lazy val messageUsService = wire[MessageUsService] -} - -trait AppComponents extends FrontendComponents with ArticleControllers with TopicServices with MessageUsServices { +trait AppComponents extends FrontendComponents with ArticleControllers with TopicServices { lazy val newsletterApi = wire[NewsletterApi] lazy val newsletterSignupAgent = wire[NewsletterSignupAgent] @@ -77,7 +65,6 @@ trait AppComponents extends FrontendComponents with ArticleControllers with Topi wire[StoreNavigationLifecycleComponent], wire[TopicLifecycle], wire[NewsletterSignupLifecycle], - wire[MessageUsLifecycle], ) lazy val router: Router = wire[Routes] diff --git a/article/app/controllers/ArticleController.scala b/article/app/controllers/ArticleController.scala index 0784e7fa8ecd..430c921cc25c 100644 --- a/article/app/controllers/ArticleController.scala +++ b/article/app/controllers/ArticleController.scala @@ -129,7 +129,6 @@ class ArticleController( blocks, pageType, newsletter, - messageUs = None, ) case HtmlFormat | AmpFormat => Future.successful(common.renderHtml(ArticleHtmlPage.html(article), article)) diff --git a/article/app/controllers/ArticleControllers.scala b/article/app/controllers/ArticleControllers.scala index 079eaf185fde..3fa4bb79c8cf 100644 --- a/article/app/controllers/ArticleControllers.scala +++ b/article/app/controllers/ArticleControllers.scala @@ -6,7 +6,7 @@ import model.{ApplicationContext, TopicsApiResponse} import play.api.libs.ws.WSClient import play.api.mvc.ControllerComponents import renderers.DotcomRenderingService -import services.{NewsletterService, NewspaperBookSectionTagAgent, NewspaperBookTagAgent, S3Client, MessageUsService} +import services.{NewsletterService, NewspaperBookSectionTagAgent, NewspaperBookTagAgent, S3Client} import services.newsletters.NewsletterSignupAgent import topics.TopicService @@ -17,7 +17,6 @@ trait ArticleControllers { def remoteRender: DotcomRenderingService def topicS3Client: S3Client[TopicsApiResponse] def topicService: TopicService - def messageUsService: MessageUsService def newsletterSignupAgent: NewsletterSignupAgent implicit def appContext: ApplicationContext diff --git a/article/app/controllers/LiveBlogController.scala b/article/app/controllers/LiveBlogController.scala index d993d677e710..cff4b9c35681 100644 --- a/article/app/controllers/LiveBlogController.scala +++ b/article/app/controllers/LiveBlogController.scala @@ -17,7 +17,7 @@ import play.api.libs.ws.WSClient import play.api.mvc._ import play.twirl.api.Html import renderers.DotcomRenderingService -import services.{CAPILookup, NewsletterService, MessageUsService} +import services.{CAPILookup, NewsletterService} import topics.TopicService import utils.DotcomponentsLogger import views.support.RenderOtherStatus @@ -33,7 +33,6 @@ class LiveBlogController( remoteRenderer: renderers.DotcomRenderingService = DotcomRenderingService(), newsletterService: NewsletterService, topicService: TopicService, - messageUsService: MessageUsService, )(implicit context: ApplicationContext) extends BaseController with GuLogging @@ -67,7 +66,6 @@ class LiveBlogController( val filter = shouldFilter(filterKeyEvents) val topicResult = if (filter) None else getTopicResult(path, topics) val availableTopics = topicService.getAvailableTopics(path) - val messageUs = messageUsService.getBlogMessageUsData(path) page.map(ParseBlockId.fromPageParam) match { case Some(ParsedBlockId(id)) => @@ -77,7 +75,6 @@ class LiveBlogController( filter, topicResult, availableTopics, - messageUs, ) // we know the id of a block case Some(InvalidFormat) => Future.successful( @@ -92,7 +89,6 @@ class LiveBlogController( filter, Some(value), availableTopics, - messageUs, ) // no page param case None => renderWithRange( @@ -101,7 +97,6 @@ class LiveBlogController( filter, None, availableTopics, - messageUs, ) // no page param } } @@ -123,7 +118,6 @@ class LiveBlogController( val topicResult = getTopicResult(path, topics) val range = getRange(lastUpdate, page, topicResult) val availableTopics = topicService.getAvailableTopics(path) - val messageUs = messageUsService.getBlogMessageUsData(path) mapModel(path, range, filter, topicResult) { case (blog: LiveBlogPage, _) if rendered.contains(false) => getJsonForFronts(blog) @@ -134,7 +128,7 @@ class LiveBlogController( * payload that would be sent to DCR when initially server side rendering the LiveBlog page. */ case (blog: LiveBlogPage, blocks) if request.forceDCR && lastUpdate.isEmpty => - Future.successful(renderDCRJson(blog, blocks, filter, availableTopics, topicResult, messageUs)) + Future.successful(renderDCRJson(blog, blocks, filter, availableTopics, topicResult)) case (blog: LiveBlogPage, blocks) => getJson( blog, @@ -160,7 +154,6 @@ class LiveBlogController( filterKeyEvents: Boolean, topicResult: Option[TopicResult], availableTopics: Option[Seq[Topic]], - messageUs: Option[MessageUsData], )(implicit request: RequestHeader, ): Future[Result] = { @@ -203,7 +196,6 @@ class LiveBlogController( request.forceLive, availableTopics, topicResult, - messageUs, ) } else { DotcomponentsLogger.logger.logRequest(s"liveblog executing in web", properties, page.article) @@ -377,7 +369,6 @@ class LiveBlogController( filterKeyEvents: Boolean, availableTopics: Option[Seq[Topic]], topicResult: Option[TopicResult], - messageUs: Option[MessageUsData], )(implicit request: RequestHeader): Result = { val pageType: PageType = PageType(blog, request, context) val newsletter = newsletterService.getNewsletterForLiveBlog(blog) @@ -393,7 +384,6 @@ class LiveBlogController( availableTopics, newsletter, topicResult, - messageUs, ) val json = DotcomRenderingDataModel.toJson(model) common.renderJson(json, blog).as("application/json") diff --git a/article/app/jobs/MessageUsLifecycle.scala b/article/app/jobs/MessageUsLifecycle.scala deleted file mode 100644 index 12fdc0bd3a92..000000000000 --- a/article/app/jobs/MessageUsLifecycle.scala +++ /dev/null @@ -1,46 +0,0 @@ -package jobs - -import app.LifecycleComponent -import common.{PekkoAsync, JobScheduler} -import play.api.inject.ApplicationLifecycle -import services.MessageUsService - -import scala.concurrent.duration._ -import scala.concurrent.{ExecutionContext, Future} - -class MessageUsLifecycle( - appLifeCycle: ApplicationLifecycle, - jobs: JobScheduler, - pekkoAsync: PekkoAsync, - messageUsService: MessageUsService, -)(implicit - ec: ExecutionContext, -) extends LifecycleComponent { - - appLifeCycle.addStopHook { () => - Future { - descheduleJobs() - } - } - - override def start(): Unit = { - descheduleJobs() - scheduleJobs() - - // refresh message us data when app starts - pekkoAsync.after1s { - messageUsService.refreshMessageUsData() - } - } - - private def scheduleJobs(): Unit = { - // This job runs every 8 minutes - jobs.scheduleEvery("MessageUsAgentRefreshJob", 8.minutes) { - messageUsService.refreshMessageUsData() - } - } - - private def descheduleJobs(): Unit = { - jobs.deschedule("MessageUsAgentRefreshJob") - } -} diff --git a/article/app/services/MessageUsService.scala b/article/app/services/MessageUsService.scala deleted file mode 100644 index 4c225df5a403..000000000000 --- a/article/app/services/MessageUsService.scala +++ /dev/null @@ -1,50 +0,0 @@ -package services - -import common.{Box, GuLogging} -import model.{MessageUsConfigData, MessageUsData} - -import scala.concurrent.{ExecutionContext, Future} - -class MessageUsService(messageUsS3Client: S3Client[MessageUsConfigData]) extends GuLogging { - - private val MAX_LIVEBLOGS_WITH_MESSAGE_US = 50 - private val messageUsConfigData = Box[Option[Map[String, MessageUsConfigData]]](None) - - def refreshMessageUsData()(implicit executionContext: ExecutionContext): Future[Unit] = { - val listOfKeys = messageUsS3Client - .getListOfKeys() - .map(keys => { - if (keys.length > MAX_LIVEBLOGS_WITH_MESSAGE_US) - log.warn(s"Over 50 live blogs are stored in S3, only caching the first 50 and ignoring the rest!") - keys.take(MAX_LIVEBLOGS_WITH_MESSAGE_US) - }) - val retrievedMessageUsConfigs = listOfKeys.map { key => - key.map { - retrieveMessageUsConfig(_) - } - } - - retrievedMessageUsConfigs - .flatMap(Future.sequence(_)) - .map(response => { - messageUsConfigData send Some(response.toMap) - log.info("successfully refreshed message us configs") - }) - .recover { - case e => - log.error(s"Could not refresh message us configs due to \'${e.getMessage}\'") - } - } - - def getBlogMessageUsData(blogId: String): Option[MessageUsData] = { - messageUsConfigData.get().flatMap(_.get(blogId)).map(c => MessageUsData(c.formId, c.formFields)) - } - - def getAllMessageUsConfigData: Option[Map[String, MessageUsConfigData]] = { - messageUsConfigData.get() - } - - private def retrieveMessageUsConfig(key: String)(implicit executionContext: ExecutionContext) = { - messageUsS3Client.getObject(key).map { res => key -> res } - } -} diff --git a/article/test/DCRFake.scala b/article/test/DCRFake.scala index c5b5be283805..306522109e70 100644 --- a/article/test/DCRFake.scala +++ b/article/test/DCRFake.scala @@ -3,7 +3,7 @@ package test import com.gu.contentapi.client.model.v1.{Block, Blocks} import model.Cached.RevalidatableResult import model.dotcomrendering.{OnwardCollectionResponse, PageType} -import model.{ApplicationContext, Cached, LiveBlogPage, PageWithStoryPackage, Topic, TopicResult, MessageUsData} +import model.{ApplicationContext, Cached, LiveBlogPage, PageWithStoryPackage, Topic, TopicResult} import play.api.libs.ws.WSClient import play.api.mvc.{RequestHeader, Result} import play.twirl.api.Html @@ -28,7 +28,6 @@ class DCRFake(implicit context: ApplicationContext) extends renderers.DotcomRend forceLive: Boolean, availableTopics: Option[Seq[Topic]], topicResult: Option[TopicResult], - messageUs: Option[MessageUsData], )(implicit request: RequestHeader): Future[Result] = { implicit val ec = ExecutionContext.global requestedBlogs.enqueue(article) diff --git a/article/test/LiveBlogControllerTest.scala b/article/test/LiveBlogControllerTest.scala index 0224795b363d..fb7c08f65ef9 100644 --- a/article/test/LiveBlogControllerTest.scala +++ b/article/test/LiveBlogControllerTest.scala @@ -9,20 +9,10 @@ import play.api.test._ import play.api.test.Helpers._ import org.scalatest.{BeforeAndAfterAll, DoNotDiscover} import org.scalatestplus.mockito.MockitoSugar -import model.{ - EmailField, - FieldType, - LiveBlogPage, - MessageUsData, - NameField, - TextAreaField, - Topic, - TopicResult, - TopicType, -} +import model.{LiveBlogPage, Topic, TopicResult, TopicType} import play.api.libs.json.{JsValue, Json} import topics.TopicService -import services.{NewsletterService, MessageUsService} +import services.{NewsletterService} import services.newsletters.{NewsletterApi, NewsletterSignupAgent} @DoNotDiscover class LiveBlogControllerTest @@ -41,7 +31,6 @@ import services.newsletters.{NewsletterApi, NewsletterSignupAgent} trait Setup { var fakeTopicService = mock[TopicService] - var fakeMessageUsService = mock[MessageUsService] var fakeDcr = new DCRFake() val topicResult = TopicResult( name = "Fifa", @@ -50,14 +39,6 @@ import services.newsletters.{NewsletterApi, NewsletterSignupAgent} count = 1, percentage_blocks = 1.2f, ) - val messageUsResult = MessageUsData( - formId = "mock-form-id", - formFields = List( - NameField("nameField1", "name", "name", true, FieldType.Name), - EmailField("emailField1", "email", "email", true, FieldType.Email), - TextAreaField("textAreaField1", "textArea", "textArea", true, FieldType.TextArea), - ), - ) val fakeAvailableTopics = Vector( Topic(TopicType.Gpe, "United Kingdom", Some(6)), @@ -84,12 +65,6 @@ import services.newsletters.{NewsletterApi, NewsletterSignupAgent} fakeAvailableTopics, ) - when( - fakeMessageUsService.getBlogMessageUsData(path), - ) thenReturn Some( - messageUsResult, - ) - lazy val liveBlogController = new LiveBlogController( testContentApiClient, play.api.test.Helpers.stubControllerComponents(), @@ -97,7 +72,6 @@ import services.newsletters.{NewsletterApi, NewsletterSignupAgent} fakeDcr, new NewsletterService(new NewsletterSignupAgent(new NewsletterApi(wsClient))), fakeTopicService, - fakeMessageUsService, ) } @@ -313,89 +287,6 @@ import services.newsletters.{NewsletterApi, NewsletterSignupAgent} liveBlogController.shouldFilter(None) should be(false) } - it should "return the message us data, if available" in new Setup { - val fakeRequest = FakeRequest( - GET, - s"${path}.json?dcr=true", - ).withHeaders("host" -> "localhost:9000") - - val result = liveBlogController.renderJson( - path, - page = None, - lastUpdate = None, - rendered = None, - isLivePage = Some(true), - filterKeyEvents = Some(false), - topics = None, - )(fakeRequest) - status(result) should be(200) - - val actualMessageUsContent: JsValue = contentAsJson(result).result.get("messageUs") - val expectedMessageUsContent: String = - """ - |{ - | "formId":"mock-form-id", - | "formFields": [ - | { - | "_type":"model.NameField", - | "name":"name", - | "label":"name", - | "id":"nameField1", - | "type":"text", - | "required":true - | }, - | { - | "_type":"model.EmailField", - | "name":"email", - | "label":"email", - | "id":"emailField1", - | "type":"email", - | "required":true - | }, - | { - | "name":"textArea", - | "label":"textArea", - | "id":"textAreaField1", - | "maxlength":1000, - | "minlength":0, - | "_type":"model.TextAreaField", - | "type":"textarea", - | "required":true - | }] - |} - |""".stripMargin - - assert(actualMessageUsContent.equals(Json.parse(expectedMessageUsContent))) - } - - it should "return no message us data, if not available" in new Setup { - when( - fakeMessageUsService.getBlogMessageUsData(path), - ) thenReturn None - - val fakeRequest = FakeRequest( - GET, - s"${path}.json?dcr=true", - ).withHeaders("host" -> "localhost:9000") - - val result = liveBlogController.renderJson( - path, - page = None, - lastUpdate = None, - rendered = None, - isLivePage = Some(true), - filterKeyEvents = Some(false), - topics = None, - )(fakeRequest) - - status(result) should be(200) - - val content = contentAsString(result) - content should not include ( - "messageUs\":{\"formId\":\"mock-form-id\",\"formFields\":[{\"_type\":\"model.NameField\",\"id\":\"nameField1\",\"label\":\"name\",\"name\":\"name\",\"required\":true,\"type\":\"text\"},{\"_type\":\"model.EmailField\",\"id\":\"emailField1\",\"label\":\"email\",\"name\":\"email\",\"required\":true,\"type\":\"email\"},{\"_type\":\"model.TextAreaField\",\"id\":\"textAreaField1\",\"label\":\"textArea\",\"name\":\"textArea\",\"required\":true,\"type\":\"textarea\",\"minlength\":0,\"maxlength\":1000}]}", - ) - } - "getTopicResult" should "returns none given no automatic filter query parameter" in new Setup { liveBlogController.getTopicResult(path, None) should be(None) } diff --git a/article/test/TestAppLoader.scala b/article/test/TestAppLoader.scala index ae9dc1c1aa0e..cac4e4524f18 100644 --- a/article/test/TestAppLoader.scala +++ b/article/test/TestAppLoader.scala @@ -2,14 +2,14 @@ import app.FrontendComponents import services.S3Client import org.mockito.Mockito._ import org.scalatestplus.mockito.MockitoSugar -import model.{MessageUsConfigData, TopicsApiResponse} +import model.{TopicsApiResponse} import play.api.ApplicationLoader.Context import play.api.BuiltInComponentsFromContext import renderers.DotcomRenderingService import test.WithTestContentApiClient import test.DCRFake -trait TestComponents extends WithTestContentApiClient with WithTestTopicService with WithTestMessageUsService { +trait TestComponents extends WithTestContentApiClient with WithTestTopicService { self: AppComponents => override lazy val contentApiClient = testContentApiClient @@ -25,10 +25,6 @@ trait WithTestTopicService extends TopicServices with MockitoSugar { override lazy val topicS3Client: S3Client[TopicsApiResponse] = mock[S3Client[TopicsApiResponse]] } -trait WithTestMessageUsService extends MessageUsServices with MockitoSugar { - override lazy val messageUsS3Client: S3Client[MessageUsConfigData] = mock[S3Client[MessageUsConfigData]] -} - class TestAppLoader extends AppLoader { override def buildComponents(context: Context): FrontendComponents = new BuiltInComponentsFromContext(context) with AppComponents with TestComponents diff --git a/article/test/services/MessageUsServiceTest.scala b/article/test/services/MessageUsServiceTest.scala deleted file mode 100644 index c893e53e78b5..000000000000 --- a/article/test/services/MessageUsServiceTest.scala +++ /dev/null @@ -1,100 +0,0 @@ -package services - -import model.{FieldType, EmailField, MessageUsConfigData, MessageUsData, NameField, TextAreaField} -import org.mockito.ArgumentMatchers.{startsWith, eq => mockitoEq} -import org.mockito.Matchers.{any, anyString} -import org.scalatest.BeforeAndAfterAll -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers -import test.WithTestExecutionContext -import org.mockito.Mockito._ -import org.scalatestplus.mockito.MockitoSugar -import play.api.{Logger, MarkerContext} -import play.api.libs.json.Reads - -import scala.concurrent.duration._ -import scala.concurrent.{Await, Future} - -class MessageUsServiceTest - extends AnyFlatSpec - with Matchers - with BeforeAndAfterAll - with WithTestExecutionContext - with MockitoSugar { - - val fakeClient = mock[S3Client[MessageUsConfigData]] - - val formFields = List( - NameField("nameField1", "name", "name", true, FieldType.Name), - EmailField("emailField1", "email", "email", true, FieldType.Email), - TextAreaField("textAreaField1", "textArea", "textArea", true, FieldType.TextArea), - ) - val successResponse = MessageUsConfigData(articleId = "key1", formId = "form1", formFields = formFields) - - "refreshMessageUsData" should "return successful future given one of the S3 object calls fails" in { - when(fakeClient.getListOfKeys()) thenReturn Future.successful(List("key1", "key2")) - when(fakeClient.getObject("key1")) thenReturn Future.successful(successResponse) - when(fakeClient.getObject("key2")) thenReturn Future.failed(new Throwable("error happend")) - - val messageUsService = new MessageUsService(fakeClient) - - val refreshJob = Await.result(messageUsService.refreshMessageUsData(), 1.second) - val results = messageUsService.getAllMessageUsConfigData - - refreshJob shouldBe a[Unit] - results should be(None) - } - - "refreshMessageUsData" should "update in memory messageUsConfigData and return successful future given one of the S3 object calls fails" in { - when(fakeClient.getListOfKeys()) thenReturn Future.successful(List("key1")) - when(fakeClient.getObject("key1")) thenReturn Future.successful(successResponse) - - val messageUsService = new MessageUsService(fakeClient) - - val refreshJob = Await.result(messageUsService.refreshMessageUsData(), 1.second) - val results = messageUsService.getAllMessageUsConfigData - - refreshJob shouldBe a[Unit] - results.isDefined should be(true) - results.get.get("key1") should equal(Some(successResponse)) - } - - "refreshMessageUsData" should "update in memory messageUsConfigData with only the first 50 items given 60 records in S3" in { - val keys = (1 until 60).map(key => s"key${key}").toList - when(fakeClient.getListOfKeys()) thenReturn Future.successful(keys) - when(fakeClient.getObject(anyString())(any[Reads[MessageUsConfigData]])) thenReturn Future.successful( - successResponse, - ) - - val messageUsService = new MessageUsService(fakeClient) - - val refreshJob = Await.result(messageUsService.refreshMessageUsData(), 1.second) - val results = messageUsService.getAllMessageUsConfigData - - refreshJob shouldBe a[Unit] - results.get.size should equal(50) - } - - "getBlogMessageUsConfigData" should "return none given a blog id that doesn't exist in cache" in { - when(fakeClient.getListOfKeys()) thenReturn Future.successful(List("key1")) - when(fakeClient.getObject("key1")) thenReturn Future.successful(successResponse) - val messageUsService = new MessageUsService(fakeClient) - - val refreshJob = Await.result(messageUsService.refreshMessageUsData(), 1.second) - val result = messageUsService.getBlogMessageUsData("key2") - - result should equal(None) - } - - "getBlogMessageUsConfigData" should "return the blog specific messageUsConfigData given a blog id that exist in cache" in { - when(fakeClient.getListOfKeys()) thenReturn Future.successful(List("key1")) - when(fakeClient.getObject("key1")) thenReturn Future.successful(successResponse) - val messageUsService = new MessageUsService(fakeClient) - - val refreshJob = Await.result(messageUsService.refreshMessageUsData(), 1.second) - val result = messageUsService.getBlogMessageUsData("key1") - - val expected = MessageUsData(formId = "form1", formFields = formFields) - result should equal(Some(expected)) - } -} diff --git a/article/test/topics/TopicServiceTest.scala b/article/test/topics/TopicServiceTest.scala index 165445acbedc..9ab7d9aa129b 100644 --- a/article/test/topics/TopicServiceTest.scala +++ b/article/test/topics/TopicServiceTest.scala @@ -63,20 +63,6 @@ class TopicServiceTest results should be(None) } - "refreshMessageUsData" should "return successful future given one of the S3 object calls fails" in { - when(fakeClient.getListOfKeys()) thenReturn Future.successful(List("key1", "key2")) - when(fakeClient.getObject("key1")) thenReturn Future.successful(successResponse) - when(fakeClient.getObject("key2")) thenReturn Future.failed(new Throwable("error happend")) - - val topicService = new TopicService(fakeClient) - - val refreshJob = Await.result(topicService.refreshTopics(), 1.second) - val results = topicService.getAllTopics - - refreshJob shouldBe a[Unit] - results should be(None) - } - "refreshTopics" should "update in memory topics and return successful future given one of the S3 object calls fails" in { when(fakeClient.getListOfKeys()) thenReturn Future.successful(List("key1")) when(fakeClient.getObject("key1")) thenReturn Future.successful(successResponse) diff --git a/common/app/common/configuration.scala b/common/app/common/configuration.scala index 2a2ffcd831a2..f7bbd1d7648f 100644 --- a/common/app/common/configuration.scala +++ b/common/app/common/configuration.scala @@ -658,8 +658,6 @@ class GuardianConfiguration extends GuLogging { lazy val frontendStoreBucket = configuration.getMandatoryStringProperty("aws.bucket") lazy val topMentionsStoreBucket = configuration.getStringProperty("aws.topMentions.bucket") - lazy val messageUsStoreBucket = - configuration.getStringProperty("aws.messageUs.bucket") lazy val notificationSns: String = configuration.getMandatoryStringProperty("sns.notification.topic.arn") lazy val videoEncodingsSns: String = configuration.getMandatoryStringProperty("sns.missing_video_encodings.topic.arn") diff --git a/common/app/model/MessageUsDataModel.scala b/common/app/model/MessageUsDataModel.scala deleted file mode 100644 index e7cbaf66eed5..000000000000 --- a/common/app/model/MessageUsDataModel.scala +++ /dev/null @@ -1,97 +0,0 @@ -package model - -import model.FieldType.FieldType -import play.api.libs.functional.syntax._ -import play.api.libs.json.Reads._ -import play.api.libs.json._ - -import scala.language.implicitConversions - -sealed trait Field { - def id: String - def label: String - def name: String - def required: Boolean - def `type`: FieldType -} - -case class EmailField( - id: String, - label: String = "email", - name: String, - required: Boolean, - `type`: FieldType = FieldType.Email, -) extends Field - -case class NameField( - id: String, - label: String = "name", - name: String, - required: Boolean, - `type`: FieldType = FieldType.Name, -) extends Field - -case class TextAreaField( - id: String, - label: String = "textarea", - name: String, - required: Boolean, - `type`: FieldType = FieldType.TextArea, - minlength: Int = 0, - maxlength: Int = 1000, -) extends Field - -object FieldType extends Enumeration { - type FieldType = Value - - val Name = Value(1, "text") - val Email = Value(2, "email") - val TextArea = Value(3, "textarea") - - implicit val format: Format[FieldType] = Json.formatEnum(this) - -} - -sealed trait FieldFormats { - private val commonFieldReads = (JsPath \ "id").read[String] and - (JsPath \ "label").read[String] and - (JsPath \ "name").read[String] and - (JsPath \ "required").read[Boolean] - - implicit val nameFieldRead: Reads[NameField] = (commonFieldReads and - Reads.pure(FieldType.Name))(NameField.apply _) - - implicit val emailFieldRead: Reads[EmailField] = (commonFieldReads and - Reads.pure(FieldType.Email))(EmailField.apply _) - - implicit val textAreaFieldRead: Reads[TextAreaField] = (commonFieldReads and - Reads.pure(FieldType.TextArea) and - (JsPath \ "minlength").read[Int] and - (JsPath \ "maxlength").read[Int])(TextAreaField.apply _) - - implicit val fieldReadFmt: Reads[Field] = Reads { js => - val fieldType: JsResult[FieldType] = (JsPath \ "type").read[FieldType].reads(js) - - fieldType.flatMap { - case FieldType.Name => nameFieldRead.reads(js) - case FieldType.Email => emailFieldRead.reads(js) - case FieldType.TextArea => textAreaFieldRead.reads(js) - } - } - - implicit val nameFieldWrite: OWrites[NameField] = Json.writes[NameField] - implicit val emailFieldWrite: OWrites[EmailField] = Json.writes[EmailField] - implicit val textAreaFieldWrite: OWrites[TextAreaField] = Json.writes[TextAreaField] - - implicit val fieldWriteFmt: Writes[Field] = Json.writes[Field] -} - -case class MessageUsData(formId: String, formFields: List[Field]) -object MessageUsData extends FieldFormats { - implicit val MessageUsDataJf: Format[MessageUsData] = Json.format[MessageUsData] -} - -case class MessageUsConfigData(articleId: String, formId: String, formFields: List[Field]) -object MessageUsConfigData extends FieldFormats { - implicit val MessageUsConfigDataJf: Format[MessageUsConfigData] = Json.format[MessageUsConfigData] -} diff --git a/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala b/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala index f1f280ab99cc..5707f408a0b7 100644 --- a/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala +++ b/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala @@ -24,7 +24,6 @@ import model.{ InteractivePage, LiveBlogPage, MediaPage, - MessageUsData, PageWithStoryPackage, Topic, TopicResult, @@ -48,7 +47,6 @@ case class DotcomRenderingDataModel( main: String, availableTopics: Option[Seq[Topic]], selectedTopics: Option[Seq[Topic]], - messageUs: Option[MessageUsData], filterKeyEvents: Boolean, pinnedPost: Option[Block], keyEvents: List[Block], @@ -121,7 +119,6 @@ object DotcomRenderingDataModel { val obj = Json.obj( "availableTopics" -> model.availableTopics, "selectedTopics" -> model.selectedTopics, - "messageUs" -> model.messageUs, "version" -> model.version, "headline" -> model.headline, "standfirst" -> model.standfirst, @@ -228,7 +225,6 @@ object DotcomRenderingDataModel { availableTopics = None, newsletter = None, topicResult = None, - messageUs = None, ) } @@ -262,7 +258,6 @@ object DotcomRenderingDataModel { availableTopics = None, newsletter = newsletter, topicResult = None, - messageUs = None, ) } @@ -385,7 +380,6 @@ object DotcomRenderingDataModel { availableTopics: Option[Seq[Topic]] = None, newsletter: Option[NewsletterData], topicResult: Option[TopicResult], - messageUs: Option[MessageUsData], ): DotcomRenderingDataModel = { val pagination = page.currentPage.pagination.map(paginationInfo => { Pagination( @@ -444,7 +438,6 @@ object DotcomRenderingDataModel { availableTopics = availableTopics, newsletter = newsletter, topicResult = topicResult, - messageUs = messageUs, ) } @@ -463,7 +456,6 @@ object DotcomRenderingDataModel { pinnedPost: Option[APIBlock] = None, availableTopics: Option[Seq[Topic]] = None, topicResult: Option[TopicResult] = None, - messageUs: Option[MessageUsData] = None, filterKeyEvents: Boolean = false, mostRecentBlockId: Option[String] = None, forceLive: Boolean = false, @@ -623,7 +615,6 @@ object DotcomRenderingDataModel { mainMediaElements = mainMediaElements, matchUrl = matchData.map(_.matchUrl), matchType = matchData.map(_.matchType), - messageUs = messageUs, nav = Nav(page, edition), openGraphData = page.getOpenGraphProperties, pageFooter = PageFooter(FooterLinks.getFooterByEdition(Edition(request))), diff --git a/common/app/renderers/DotcomRenderingService.scala b/common/app/renderers/DotcomRenderingService.scala index aa315597c05b..23714e3fd715 100644 --- a/common/app/renderers/DotcomRenderingService.scala +++ b/common/app/renderers/DotcomRenderingService.scala @@ -18,7 +18,6 @@ import model.{ InteractivePage, LiveBlogPage, MediaPage, - MessageUsData, NoCache, PageWithStoryPackage, PressedPage, @@ -148,7 +147,7 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload newsletter: Option[NewsletterData], filterKeyEvents: Boolean = false, )(implicit request: RequestHeader): Future[Result] = - baseArticleRequest("/AMPArticle", ws, page, blocks, pageType, filterKeyEvents, false, None, newsletter, None, None) + baseArticleRequest("/AMPArticle", ws, page, blocks, pageType, filterKeyEvents, false, None, newsletter, None) def getAppsArticle( ws: WSClient, @@ -160,7 +159,6 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload forceLive: Boolean = false, availableTopics: Option[Seq[Topic]] = None, topicResult: Option[TopicResult] = None, - messageUs: Option[MessageUsData] = None, )(implicit request: RequestHeader): Future[Result] = baseArticleRequest( "/AppsArticle", @@ -173,7 +171,6 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload availableTopics, newsletter, topicResult, - messageUs, ) def getArticle( @@ -186,7 +183,6 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload forceLive: Boolean = false, availableTopics: Option[Seq[Topic]] = None, topicResult: Option[TopicResult] = None, - messageUs: Option[MessageUsData] = None, )(implicit request: RequestHeader): Future[Result] = baseArticleRequest( "/Article", @@ -199,7 +195,6 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload availableTopics, newsletter, topicResult, - messageUs, ) private def baseArticleRequest( @@ -213,7 +208,6 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload availableTopics: Option[Seq[Topic]] = None, newsletter: Option[NewsletterData], topicResult: Option[TopicResult], - messageUs: Option[MessageUsData], )(implicit request: RequestHeader): Future[Result] = { val dataModel = page match { case liveblog: LiveBlogPage => @@ -227,7 +221,6 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload availableTopics, newsletter, topicResult, - messageUs, ) case _ => DotcomRenderingDataModel.forArticle(page, blocks, request, pageType, newsletter) } diff --git a/dev-build/app/AppLoader.scala b/dev-build/app/AppLoader.scala index 70e0ee79465d..4ce9af73d0a6 100644 --- a/dev-build/app/AppLoader.scala +++ b/dev-build/app/AppLoader.scala @@ -21,7 +21,7 @@ import dfp.DfpDataCacheLifecycle import feed._ import football.controllers._ import http.{CorsHttpErrorHandler, DevBuildParametersHttpRequestHandler, DevFilters} -import jobs.{MessageUsLifecycle, TopicLifecycle} +import jobs.TopicLifecycle import model.{AdminLifecycle, ApplicationIdentity} import play.api.ApplicationLoader.Context import play.api._ @@ -70,8 +70,7 @@ trait AppComponents with OnwardServices with FapiServices with ApplicationsServices - with TopicServices - with MessageUsServices { + with TopicServices { //Overriding conflicting members override lazy val ophanApi = wire[OphanApi] @@ -113,7 +112,6 @@ trait AppComponents wire[NewsletterSignupLifecycle], wire[TopicLifecycle], wire[MostViewedLifecycle], - wire[MessageUsLifecycle], ) override lazy val httpFilters = wire[DevFilters].filters diff --git a/preview/app/AppLoader.scala b/preview/app/AppLoader.scala index 16f7b85d92fa..ede57304cd22 100644 --- a/preview/app/AppLoader.scala +++ b/preview/app/AppLoader.scala @@ -20,7 +20,7 @@ import dev.DevAssetsController import feed.OnwardJourneyLifecycle import football.controllers.FootballControllers import http.{Filters, GuardianAuthWithExemptions, PreviewContentSecurityPolicyFilter, PreviewNoCacheFilter, routes} -import jobs.{MessageUsLifecycle, TopicLifecycle} +import jobs.TopicLifecycle import model.ApplicationIdentity import play.api.ApplicationLoader.Context import play.api.http.HttpErrorHandler @@ -42,8 +42,7 @@ trait PreviewLifecycleComponents with FapiServices with OnwardServices with ApplicationsServices - with TopicServices - with MessageUsServices { + with TopicServices { self: FrontendComponents => //Override conflicting members @@ -68,7 +67,6 @@ trait PreviewLifecycleComponents wire[CloudWatchMetricsLifecycle], wire[NewsletterSignupLifecycle], wire[TopicLifecycle], - wire[MessageUsLifecycle], ) def pekkoActorSystem: PekkoActorSystem