aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/ActivityPubManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/ActivityPubManager.java')
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java27
1 files changed, 15 insertions, 12 deletions
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> 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());