Skip to content

Commit 16c84c3

Browse files
committed
hardcode user agent
1 parent d373f21 commit 16c84c3

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

application/config.json.template

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,7 @@
173173
}
174174
],
175175
"fallbackChannelPattern": "java-news-and-changes",
176-
"pollIntervalInMinutes": 10,
177-
"clientRequestHeaders": {
178-
"User-Agent": "TJ-Bot/1.0 (+https://github.com/Together-Java/TJ-Bot)",
179-
"Accept": "application/xml;",
180-
"Accept-Language": "en-US;"
181-
}
176+
"pollIntervalInMinutes": 10
182177
},
183178
"memberCountCategoryPattern": "Info"
184179
}

application/src/main/java/org/togetherjava/tjbot/config/RSSFeedsConfig.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44

55
import java.util.List;
6-
import java.util.Map;
76
import java.util.Objects;
87

98
/**
@@ -13,21 +12,18 @@
1312
* @param feeds The list of RSS feeds to subscribe to.
1413
* @param fallbackChannelPattern The pattern used to identify the fallback text channel to use.
1514
* @param pollIntervalInMinutes The interval (in minutes) for polling the RSS feeds for updates.
16-
* @param clientRequestHeaders The headers that will be sent with each request to the RSS feeds.
1715
*/
1816
public record RSSFeedsConfig(@JsonProperty(value = "feeds", required = true) List<RSSFeed> feeds,
1917
@JsonProperty(value = "fallbackChannelPattern",
2018
required = true) String fallbackChannelPattern,
21-
@JsonProperty(value = "pollIntervalInMinutes", required = true) int pollIntervalInMinutes,
22-
@JsonProperty(value = "clientRequestHeaders") Map<String, String> clientRequestHeaders) {
19+
@JsonProperty(value = "pollIntervalInMinutes", required = true) int pollIntervalInMinutes) {
2320

2421
/**
2522
* Constructs a new {@link RSSFeedsConfig}.
2623
*
2724
* @param feeds The list of RSS feeds to subscribe to.
2825
* @param fallbackChannelPattern The pattern used to identify the fallback text channel to use.
2926
* @param pollIntervalInMinutes The interval (in minutes) for polling the RSS feeds for updates.
30-
* @param clientRequestHeaders The headers that will be sent with each request to the RSS feeds.
3127
* @throws NullPointerException if any of the parameters (feeds or fallbackChannelPattern) are
3228
* null
3329
*/

application/src/main/java/org/togetherjava/tjbot/features/rss/RSSHandlerRoutine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public final class RSSHandlerRoutine implements Routine {
7474
private static final int MAX_CONTENTS = 1000;
7575
private static final ZonedDateTime ZONED_TIME_MIN =
7676
ZonedDateTime.of(LocalDateTime.MIN, ZoneId.systemDefault());
77+
private static final String HTTP_USER_AGENT =
78+
"TJ-Bot/1.0 (+https://github.com/Together-Java/TJ-Bot)";
7779
private final RssReader rssReader;
7880
private final RSSFeedsConfig config;
7981
private final Predicate<String> fallbackChannelPattern;
@@ -103,7 +105,7 @@ public RSSHandlerRoutine(Config config, Database database) {
103105
});
104106

105107
this.rssReader = new RssReader();
106-
this.config.clientRequestHeaders().forEach(this.rssReader::addHeader);
108+
this.rssReader.setUserAgent(HTTP_USER_AGENT);
107109
}
108110

109111
@Override

0 commit comments

Comments
 (0)