From 8eeac22c25fdc83351bcbbb388de2f0e9b28a70f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 31 Jan 2020 14:06:51 +0300 Subject: ActivityPub: process top event exception --- src/main/java/com/juick/server/ActivityPubManager.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/juick/server/ActivityPubManager.java b/src/main/java/com/juick/server/ActivityPubManager.java index 18470b16..6053695a 100644 --- a/src/main/java/com/juick/server/ActivityPubManager.java +++ b/src/main/java/com/juick/server/ActivityPubManager.java @@ -382,13 +382,15 @@ public class ActivityPubManager implements ActivityListener, NotificationListene announce.setObject(note); Person me = (Person) signatureManager.getContext(URI.create(announce.getActor())).get(); socialService.getFollowers(serviceUser).forEach(acct -> { - Person follower = (Person) signatureManager.getContext(URI.create(acct)).get(); - try { - logger.info("Announcing top: {}", message.getMid()); - signatureManager.post(me, follower, announce); - } catch (IOException e) { - logger.warn("activitypub exception", e); - } + var follower = signatureManager.getContext(URI.create(acct)); + follower.ifPresentOrElse((person) -> { + try { + logger.info("Announcing top: {}", message.getMid()); + signatureManager.post(me, (Person)person, announce); + } catch (IOException e) { + logger.warn("activitypub exception", e); + } + }, () -> logger.warn("Follower not found: {}", acct)); }); } public User personToUser(URI uri) throws HttpBadRequestException { -- cgit v1.2.3