Skip to content

Commit

Permalink
Add author first and last name to each rss news item. (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip-Ramslov authored Jan 25, 2024
1 parent 4433095 commit 49e38b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class RssConverter {
*/
public static com.rometools.rome.feed.rss.Item toRssItem(Item item,
Function<Item, String> titleMapper,
Function<Item, String> authorMapper,
Function<Item, String> contentMapper,
Function<Item, String> linkMapper) {
var rssItem = new com.rometools.rome.feed.rss.Item();
Expand All @@ -24,6 +25,7 @@ public static com.rometools.rome.feed.rss.Item toRssItem(Item item,
description.setValue(contentMapper.apply(item));

rssItem.setTitle(titleMapper.apply(item));
rssItem.setAuthor(authorMapper.apply(item));
rssItem.setDescription(description);
rssItem.setPubDate(ldtToDate(item.getPublishDate()));
rssItem.setLink(linkMapper.apply(item));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ public RssView englishFeed() {

private List<com.rometools.rome.feed.rss.Item> fetchAndConvertSwedishItems() {
return fetchAndConvertItems(Item::getTitleSwedish,
Item::getAuthorDisplay,
Item::getContentSwedishProcessed,
i -> RssConstants.Swedish.LINK_BASE_URL + i.getId());
}

private List<com.rometools.rome.feed.rss.Item> fetchAndConvertEnglishItems() {
return fetchAndConvertItems(Item::getTitleEnglish,
Item::getAuthorDisplay,
Item::getContentEnglishProcessed,
i -> RssConstants.English.LINK_BASE_URL + i.getId());
}

private List<com.rometools.rome.feed.rss.Item> fetchAndConvertItems(Function<Item, String> titleMapper,
Function<Item, String> authorMapper,
Function<Item, String> contentMapper,
Function<Item, String> linkMapper) {

Expand All @@ -62,7 +65,7 @@ private List<com.rometools.rome.feed.rss.Item> fetchAndConvertItems(Function<Ite
.getContent()
.stream();
return (receptionRepository.get().getState() ? sensitive : all)
.map(i -> RssConverter.toRssItem(i, titleMapper, contentMapper, linkMapper))
.map(i -> RssConverter.toRssItem(i, titleMapper, authorMapper, contentMapper, linkMapper))
.collect(Collectors.toList());
}

Expand Down

0 comments on commit 49e38b9

Please sign in to comment.