Skip to content

Commit

Permalink
#12 Add third media source : added
Browse files Browse the repository at this point in the history
  • Loading branch information
Serwios committed Apr 6, 2023
1 parent 190afc0 commit 21db110
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public List<SimplePostEvent> 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();
}
Expand Down

0 comments on commit 21db110

Please sign in to comment.