From 06cbddff34ce33cfff4fd6a265c5752cc95a6e53 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 24 Mar 2021 18:01:05 +0300 Subject: ActivityPub: handle unverified updates --- src/main/java/com/juick/ActivityPubManager.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java index 22fe826f..61431c71 100644 --- a/src/main/java/com/juick/ActivityPubManager.java +++ b/src/main/java/com/juick/ActivityPubManager.java @@ -61,6 +61,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -186,15 +187,17 @@ public class ActivityPubManager implements ActivityListener, NotificationListene User user = event.getUser(); String userUri = personUri(user); Person me = (Person) signatureManager.getContext(URI.create(userUri)).get(); - socialService.getFollowers(user).forEach(acct -> { - Person follower = (Person) signatureManager.getContext(URI.create(acct)).get(); - Update update = new Update(); - update.setId(objectUri + "#update"); - update.setActor(me.getId()); - update.setObject(objectUri); + socialService.getFollowers(user).forEach(acct -> { try { + Person follower = (Person) signatureManager.getContext(URI.create(acct)).orElseThrow(); + Update update = new Update(); + update.setId(objectUri + "#update"); + update.setActor(me.getId()); + update.setObject(objectUri); logger.info("Update to follower {}", follower.getId()); signatureManager.post(me, follower, update); + } catch (NoSuchElementException e) { + logger.warn("Person not verified: {}", acct); } catch (IOException | NoSuchAlgorithmException e) { logger.warn("activitypub exception", e); } -- cgit v1.2.3