From 21db11065e34bdb020fd971edd38a93a4daf7a0c Mon Sep 17 00:00:00 2001 From: Serwio YK <56473255+Serwios@users.noreply.github.com> Date: Thu, 6 Apr 2023 23:11:25 +0300 Subject: [PATCH] #12 Add third media source : added --- .../bot/command/user/ShowMediaCommand.java | 4 +++- .../broadcaster/domain/SimplePostEvent.java | 2 +- .../postgather/ZDNetPostGather.java | 20 +++++++++++++++++++ .../postsource/ZDNetPostSource.java | 17 ++++++++++++++++ .../broadcaster/rss/RssFeedUrl.java | 3 ++- .../broadcaster/rss/RssPostsResolver.java | 2 +- 6 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/archivision/broadcaster/postgather/ZDNetPostGather.java create mode 100644 src/main/java/com/archivision/broadcaster/postsource/ZDNetPostSource.java diff --git a/src/main/java/com/archivision/broadcaster/bot/command/user/ShowMediaCommand.java b/src/main/java/com/archivision/broadcaster/bot/command/user/ShowMediaCommand.java index 35623c2..04f93ce 100644 --- a/src/main/java/com/archivision/broadcaster/bot/command/user/ShowMediaCommand.java +++ b/src/main/java/com/archivision/broadcaster/bot/command/user/ShowMediaCommand.java @@ -11,7 +11,9 @@ public class ShowMediaCommand implements RequestCommand { public CommunicationData perform(CommunicationData data) { return new CommunicationData(""" Here is currently available media resources: - Medium + The Verge + CNN + Wired """, data.telegramUserId()); } diff --git a/src/main/java/com/archivision/broadcaster/domain/SimplePostEvent.java b/src/main/java/com/archivision/broadcaster/domain/SimplePostEvent.java index 750799f..f3f8ae8 100644 --- a/src/main/java/com/archivision/broadcaster/domain/SimplePostEvent.java +++ b/src/main/java/com/archivision/broadcaster/domain/SimplePostEvent.java @@ -18,6 +18,6 @@ public final class SimplePostEvent implements PostEvent { @Override public String getBodyText() { - return mediaOriginName + "\n\n" + title + "\n\n" + description + "\n\n" + postTime + "\n\n" + linkToOriginal; + return title + "\n\n" + description + "\n\n" + postTime + "\n\n" + linkToOriginal; } } diff --git a/src/main/java/com/archivision/broadcaster/postgather/ZDNetPostGather.java b/src/main/java/com/archivision/broadcaster/postgather/ZDNetPostGather.java new file mode 100644 index 0000000..f1898eb --- /dev/null +++ b/src/main/java/com/archivision/broadcaster/postgather/ZDNetPostGather.java @@ -0,0 +1,20 @@ +package com.archivision.broadcaster.postgather; + +import com.archivision.broadcaster.rss.RssPostsResolver; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import static com.archivision.broadcaster.rss.RssFeedUrl.ZDNET; + +@Component +@Slf4j +public class ZDNetPostGather extends AbstractRssPostGather { + public ZDNetPostGather(PostHandler postHandler, RssPostsResolver rssPostsResolver) { + super(postHandler, rssPostsResolver); + } + + @Override + public String getRssUri() { + return ZDNET.getUrl(); + } +} diff --git a/src/main/java/com/archivision/broadcaster/postsource/ZDNetPostSource.java b/src/main/java/com/archivision/broadcaster/postsource/ZDNetPostSource.java new file mode 100644 index 0000000..290e354 --- /dev/null +++ b/src/main/java/com/archivision/broadcaster/postsource/ZDNetPostSource.java @@ -0,0 +1,17 @@ +package com.archivision.broadcaster.postsource; + +import com.archivision.broadcaster.postgather.PostGather; +import com.archivision.broadcaster.postgather.ZDNetPostGather; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ZDNetPostSource extends AbstractPostSource { + private final ZDNetPostGather ZDNetPostGather; + + @Override + public PostGather getPostGather() { + return ZDNetPostGather; + } +} diff --git a/src/main/java/com/archivision/broadcaster/rss/RssFeedUrl.java b/src/main/java/com/archivision/broadcaster/rss/RssFeedUrl.java index 1f2b065..2f8212c 100644 --- a/src/main/java/com/archivision/broadcaster/rss/RssFeedUrl.java +++ b/src/main/java/com/archivision/broadcaster/rss/RssFeedUrl.java @@ -2,7 +2,8 @@ public enum RssFeedUrl { CNN("http://rss.cnn.com/rss/cnn_latest.rss"), - WIRED("https://www.wired.com/feed/rss"); + WIRED("https://www.wired.com/feed/rss"), + ZDNET("https://www.zdnet.com/news/rss.xml"); private final String url; diff --git a/src/main/java/com/archivision/broadcaster/rss/RssPostsResolver.java b/src/main/java/com/archivision/broadcaster/rss/RssPostsResolver.java index 9114927..7bc745b 100644 --- a/src/main/java/com/archivision/broadcaster/rss/RssPostsResolver.java +++ b/src/main/java/com/archivision/broadcaster/rss/RssPostsResolver.java @@ -38,7 +38,7 @@ public List resolveBatchFromRssUrl(String endpoint) { final String title = entry.getTitle(); SyndContent syndContent = entry.getDescription(); - String description = "*Empty*"; + String description = "*Service settled empty description*"; if (syndContent != null) { description = syndContent.getValue(); }