diff options
author | Vitaly Takmazov | 2021-03-24 18:01:05 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-03-24 18:01:05 +0300 |
commit | 06cbddff34ce33cfff4fd6a265c5752cc95a6e53 (patch) | |
tree | 8b6db712f9def93eb9d08f9f0fdbffca774bc5e8 /src/main | |
parent | 167e89dfa55e10f63dec42769014a4464fd8dbd4 (diff) |
ActivityPub: handle unverified updates
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/juick/ActivityPubManager.java | 15 |
1 files changed, 9 insertions, 6 deletions
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); } |