From 0213858d0a9eeeb1d1ac3c60ceb1c721c8569a01 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 31 Dec 2022 01:12:21 +0300 Subject: ActivityPub: cleanup logging --- src/main/java/com/juick/ActivityPubManager.java | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/juick/ActivityPubManager.java') diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java index 63417626..1dd3b784 100644 --- a/src/main/java/com/juick/ActivityPubManager.java +++ b/src/main/java/com/juick/ActivityPubManager.java @@ -106,7 +106,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene @Override public void deleteUserEvent(DeleteUserEvent event) { String acct = event.getUserUri(); - logger.info("Deleting {} from followers", acct); + logger.debug("Deleting {} from followers", acct); socialService.removeAccount(acct); } @@ -201,14 +201,18 @@ public class ActivityPubManager implements ActivityListener, NotificationListene Actor me = conversionService.convert(user, Actor.class); socialService.getFollowers(user).forEach(acct -> { try { - Actor follower = (Actor) signatureManager.getContext(URI.create(acct)).orElseThrow(); - Update update = new Update(); - update.setId(userUri + "#update"); - update.setActor(me.getId()); - update.setObject(me); - update.setPublished(Instant.now()); - logger.info("Update to follower {}", follower.getId()); - signatureManager.post(me, follower, update); + var context = signatureManager.getContext(URI.create(acct)); + if (context.isPresent() && context.get() instanceof Actor follower) { + Update update = new Update(); + update.setId(userUri + "#update"); + update.setActor(me.getId()); + update.setObject(me); + update.setPublished(Instant.now()); + logger.info("Update to follower {}", follower.getId()); + signatureManager.post(me, follower, update); + } else { + logger.warn("Unhandled context: {}", acct); + } } catch (Exception e) { logger.warn("activitypub exception", e); } @@ -233,9 +237,8 @@ public class ActivityPubManager implements ActivityListener, NotificationListene subscribers.addAll(note.getCc()); subscribers.forEach(acct -> { if (!acct.equals(profileUriBuilder.followersUri(user))) { - Optional context = signatureManager.getContext(URI.create(acct)); - if (context.isPresent() && context.get() instanceof Actor) { - Actor follower = (Actor) context.get(); + var context = signatureManager.getContext(URI.create(acct)); + if (context.isPresent() && context.get() instanceof Actor follower) { Create create = new Create(); create.setId(note.getId()); create.setActor(me.getId()); -- cgit v1.2.3