Skip to content
Permalink
Browse files
Parse older conversations, but only the most recent messages
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Mar 6, 2020
1 parent 0ec5b37 commit bf4d75aa8c360e9c3f9abc95b9a786b7750b6790
Showing 2 changed files with 5 additions and 2 deletions.
@@ -57,7 +57,7 @@ public boolean concurrentWith(WorkItem other) {
@Override
public void run(Path scratchPath) {
// Give the bot a chance to act on all found messages
var conversations = list.conversations(Duration.ofDays(60));
var conversations = list.conversations(Duration.ofDays(365));
for (var conversation : conversations) {
bot.inspect(conversation);
}
@@ -27,6 +27,7 @@
import org.openjdk.skara.forge.*;
import org.openjdk.skara.mailinglist.*;

import java.time.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.logging.Logger;
@@ -92,8 +93,10 @@ synchronized void inspect(Conversation conversation) {
parsedEmailIds.remove(first.id());
}

// Are there any new messages?
// Are there any new messages? We avoid looking further back than 14 days. If the bridge has been down
// for more than 14 days, this may have to be temporarily increased.
var newMessages = conversation.allMessages().stream()
.filter(email -> email.date().isAfter(ZonedDateTime.now().minus(Duration.ofDays(14))))
.filter(email -> !parsedEmailIds.contains(email.id()))
.collect(Collectors.toList());
if (newMessages.isEmpty()) {

0 comments on commit bf4d75a

Please sign in to comment.