diff options
author | Vitaly Takmazov | 2018-10-24 19:06:59 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-24 19:06:59 +0300 |
commit | 2b2b408e0a4937aa417af485ed1d5bcea41e36a6 (patch) | |
tree | 2ba60430be359ead75f77ed744e83c3cc9cb9955 /juick-server/src/main | |
parent | 0080c338b062b597b721ff6e6ae3eae96a6be487 (diff) |
ActivityPub: add reply author to cc
Diffstat (limited to 'juick-server/src/main')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/ActivityPubManager.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java index 1005b077..1ffd376b 100644 --- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java +++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java @@ -33,8 +33,10 @@ import java.io.Writer; import java.net.URI; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; @Component @@ -133,7 +135,13 @@ public class ActivityPubManager implements ActivityListener, NotificationListene String userUri = personUri(user); Note note = makeNote(msg); Person me = (Person) signatureManager.getContext(URI.create(userUri)).get(); - socialService.getFollowers(user).forEach(acct -> { + 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); + note.getCc().add(replier); + } + subscribers.forEach(acct -> { Optional<Context> context = signatureManager.getContext(URI.create(acct)); if (context.isPresent()) { Person follower = (Person)context.get(); @@ -143,7 +151,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene create.setPublished(note.getPublished()); create.setObject(note); try { - logger.info("Posting to follower {}", follower.getId()); + logger.info("Posting to subscriber {}", follower.getId()); signatureManager.post(me, follower, create); } catch (IOException e) { logger.warn("activitypub exception", e); |