aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-04-13 15:43:19 +0300
committerGravatar Vitaly Takmazov2022-04-13 15:43:19 +0300
commitcde193ed381f8734701649fa6af6b77560c2682f (patch)
tree9ece86de875207df2b9b14392dd6cb75cae82e6d
parent5627cc16cc8059e09a844ff5c9609051c2961847 (diff)
ActivityPub: handle like exceptions
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java
index 621a89c2..b0e77c63 100644
--- a/src/main/java/com/juick/ActivityPubManager.java
+++ b/src/main/java/com/juick/ActivityPubManager.java
@@ -411,17 +411,24 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
announce.setActor(personUri(user));
announce.setTo(Collections.singletonList(Context.ACTIVITYSTREAMS_PUBLIC));
announce.setObject(note);
- Actor me = (Actor) signatureManager.getContext(URI.create(announce.getActor())).get();
- socialService.getFollowers(user).forEach(acct -> {
- var follower = signatureManager.getContext(URI.create(acct));
- follower.ifPresentOrElse((person) -> {
- try {
- logger.info("{} announcing {} to {}", user.getName(), message.getMid(), acct);
- signatureManager.post(me, (Actor)person, announce);
- } catch (IOException | NoSuchAlgorithmException e) {
- logger.warn("activitypub exception", e);
- }
- }, () -> logger.warn("Follower not found: {}", acct));
+ signatureManager.getContext(URI.create(announce.getActor())).ifPresentOrElse((ctx) -> {
+ if (ctx instanceof Actor) {
+ socialService.getFollowers(user).forEach(acct -> {
+ var follower = signatureManager.getContext(URI.create(acct));
+ follower.ifPresentOrElse((person) -> {
+ try {
+ logger.info("{} announcing {} to {}", user.getName(), message.getMid(), acct);
+ signatureManager.post((Actor)ctx, (Actor) person, announce);
+ } catch (IOException | NoSuchAlgorithmException e) {
+ logger.warn("activitypub exception", e);
+ }
+ }, () -> logger.warn("Follower not found: {}", acct));
+ });
+ } else {
+ logger.warn("Unhandled context: {}", announce.getActor());
+ }
+ }, () -> {
+ logger.warn("Context not found: {}", announce.getActor());
});
}
public User actorToUser(URI uri) throws HttpBadRequestException {