Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Fixed and updated the StopModReposts API #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ public static void check(ModDirector director, URL url) throws ModDirectorExcept
director.getLogger().log(ModDirectorSeverityLevel.DEBUG, "StopModReposts", "CORE",
"Checking %s against StopModReposts database", url.toExternalForm());
for(StopModRepostsEntry entry : ENTRIES) {
if(entry.pattern().matcher(url.toExternalForm()).matches()) {
if(url.toExternalForm().contains(entry.domain()) ) {
director.getLogger().log(ModDirectorSeverityLevel.ERROR, "StopModReposts", "CORE",
"STOP! Download URL %s is flagged in StopModReposts database, ABORTING!",
url.toExternalForm());
director.getLogger().log(ModDirectorSeverityLevel.ERROR, "StopModReposts", "CORE",
"Domain %s is flagged", entry.domain());
director.getLogger().log(ModDirectorSeverityLevel.ERROR, "StopModReposts", "CORE",
"Advertising score: %d", entry.advertising());
director.getLogger().log(ModDirectorSeverityLevel.ERROR, "StopModReposts", "CORE",
"Redistribution score: %d", entry.redistribution());
director.getLogger().log(ModDirectorSeverityLevel.ERROR, "StopModReposts", "CORE",
"Miscellaneous: ", entry.miscellaneous());
"Reason: ", entry.reason());
if(!entry.notes().isEmpty()) {
director.getLogger().log(ModDirectorSeverityLevel.ERROR, "StopModReposts", "CORE",
"Notes: ", entry.notes());
Expand All @@ -64,14 +60,14 @@ private static void initialize(ModDirector director) throws ModDirectorException
"Initializing StopModReposts module");

try(WebGetResponse response =
WebClient.get(new URL("https://api.varden.info/smr/sitelist.php?format=json"))) {
WebClient.get(new URL("https://api.stopmodreposts.org/sites.json"))) {
JavaType targetType = ConfigurationController.OBJECT_MAPPER.getTypeFactory().
constructCollectionType(List.class, StopModRepostsEntry.class);

ENTRIES.addAll(ConfigurationController.OBJECT_MAPPER.readValue(response.getInputStream(), targetType));
} catch(MalformedURLException e) {
throw new RuntimeException(
"https://api.varden.info/smr/sitelist.php?format=json seems to be an invalid URL?", e);
"https://api.stopmodreposts.org/sites.json seems to be an invalid URL?", e);
} catch(IOException e) {
throw new ModDirectorException("Failed to retrieve StopModReposts database", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,19 @@
public class StopModRepostsEntry {
private final String domain;
private final String path;
private final Pattern pattern;
private final int advertising;
private final int redistribution;
private final int miscellaneous;
private final String reason;
private final String notes;

@JsonCreator
public StopModRepostsEntry(
@JsonProperty(value = "domain", required = true) String domain,
@JsonProperty(value = "path", required = true) String path,
@JsonProperty(value = "pattern", required = true) Pattern pattern,
@JsonProperty(value = "advertising", required = true) int advertising,
@JsonProperty(value = "redistribution", required = true) int redistribution,
@JsonProperty(value = "miscellaneous", required = true) int miscellaneous,
@JsonProperty(value = "reason", required = true) String reason,
@JsonProperty(value = "notes", required = true) String notes
) {
this.domain = domain;
this.path = path;
this.pattern = pattern;
this.advertising = advertising;
this.redistribution = redistribution;
this.miscellaneous = miscellaneous;
this.reason = reason;
this.notes = notes;
}

Expand All @@ -40,21 +31,9 @@ public String domain() {
public String path() {
return path;
}

public Pattern pattern() {
return pattern;
}

public int advertising() {
return advertising;
}

public int redistribution() {
return redistribution;
}

public int miscellaneous() {
return miscellaneous;

public int reason() {
return reason;
}

public String notes() {
Expand Down