aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java
index a86fc301..52343d9c 100644
--- a/src/main/java/com/juick/ActivityPubManager.java
+++ b/src/main/java/com/juick/ActivityPubManager.java
@@ -249,31 +249,34 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
User user = msg.getUser();
String userUri = personUri(user);
Note note = makeNote(msg);
- Actor me = (Actor) signatureManager.getContext(URI.create(userUri)).get();
- Set<String> subscribers = new HashSet<>(socialService.getFollowers(user));
- if (MessageUtils.isReply(msg) && msg.getTo().getUri().toASCIIString().length() > 0) {
- String replier = msg.getTo().getUri().toASCIIString();
- subscribers.add(replier);
- List<String> cc = new ArrayList<>(note.getCc());
- cc.add(replier);
- note.setCc(cc);
- }
- subscribers.addAll(note.getCc());
- subscribers.forEach(acct -> {
- Optional<Context> context = signatureManager.getContext(URI.create(acct));
- if (context.isPresent() && context.get() instanceof Actor) {
- Actor follower = (Actor)context.get();
- Create create = new Create();
- create.setId(note.getId());
- create.setActor(me.getId());
- create.setPublished(note.getPublished());
- create.setObject(note);
- try {
- signatureManager.post(me, follower, create);
- } catch (IOException | NoSuchAlgorithmException e) {
- logger.warn("activitypub exception", e);
- }
+ signatureManager.getContext(URI.create(userUri)).ifPresentOrElse((me) -> {
+ Set<String> subscribers = new HashSet<>(socialService.getFollowers(user));
+ if (MessageUtils.isReply(msg) && msg.getTo().getUri().toASCIIString().length() > 0) {
+ String replier = msg.getTo().getUri().toASCIIString();
+ subscribers.add(replier);
+ List<String> cc = new ArrayList<>(note.getCc());
+ cc.add(replier);
+ note.setCc(cc);
}
+ subscribers.addAll(note.getCc());
+ subscribers.forEach(acct -> {
+ Optional<Context> context = signatureManager.getContext(URI.create(acct));
+ if (context.isPresent() && context.get() instanceof Actor) {
+ Actor follower = (Actor) context.get();
+ Create create = new Create();
+ create.setId(note.getId());
+ create.setActor(me.getId());
+ create.setPublished(note.getPublished());
+ create.setObject(note);
+ try {
+ signatureManager.post((Actor)me, follower, create);
+ } catch (IOException | NoSuchAlgorithmException e) {
+ logger.warn("activitypub exception", e);
+ }
+ }
+ });
+ }, () -> {
+ logger.warn("Context not found: {}", userUri);
});
}