in src/main/scala/com/gu/mobile/content/notifications/lib/ContentAlertPayloadBuilder.scala [29:59]
def buildPayLoad(content: Content): ContentAlertPayload = {
val tagTypeSeries: Option[Tag] = content.tags.find(_.`type` == TagType.Series)
val tagTypeBlog: Option[Tag] = content.tags
.filterNot(tag => tag.id.contains("commentisfree/commentisfree"))
.find(_.`type` == TagType.Blog)
val tagTypeContributor: List[Tag] = content.tags.filter(_.`type` == TagType.Contributor).toList
val followableTag: List[Tag] = (tagTypeSeries, tagTypeBlog, tagTypeContributor) match {
case (Some(tagSeries), _, _) => List(tagSeries)
case (None, Some(tagBlog), _) => List(tagBlog)
case (None, None, tagContributor) => tagContributor.take(3)
}
val topics = content.tags
.filter(tag => followableTopicTypes.contains(tag.`type`))
.flatMap(tagToTopic)
.take(3)
.toList
ContentAlertPayload(
title = contentTitle(followableTag, topics),
message = Some(content.fields.flatMap { cf => cf.headline }.getOrElse(content.webTitle)),
imageUrl = selectMainImage(content, minWidth = 750).map(new URI(_)),
thumbnailUrl = content.thumbNail.map(new URI(_)),
sender = Sender,
link = getGuardianLink(content),
importance = Importance.Major,
topic = topics,
debug = false,
dryRun = None)
}