From fdc329f367e5685cc9d4b0654f53eaa03818e905 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 4 Oct 2018 13:25:34 +0300 Subject: AcitvityPub: correct addressing for replies and pms --- .../src/main/java/com/juick/server/ActivityPubManager.java | 12 ++++++++++-- .../java/com/juick/server/api/activity/model/Note.java | 14 +++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'juick-server/src/main/java/com') 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 ded04313..223d28fd 100644 --- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java +++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java @@ -114,8 +114,16 @@ public class ActivityPubManager implements ApplicationListener, Not Note note = new Note(); note.setId(uri.replacePath(String.format("/m/%d", msg.getMid())).toUriString()); note.setAttributedTo(personUri(msg.getUser())); - note.setTo(Collections.singletonList("https://www.w3.org/ns/activitystreams#Public")); - note.setCc(Collections.singletonList(followersUri(msg.getUser()))); + if (MessageUtils.isReply(msg)) { + uri.replacePath(String.format("/m/%d#%d", msg.getMid(), msg.getRid())).toUriString(); + note.setInReplyTo(uri.replacePath(String.format("/m/%d#%d", msg.getMid(), msg.getReplyto())).toUriString()); + } + if (MessageUtils.isPM(msg)) { + note.setTo(Collections.singletonList(activityPubManager.personUri(msg.getTo()))); + } else { + note.setTo(Collections.singletonList("https://www.w3.org/ns/activitystreams#Public")); + note.setCc(Collections.singletonList(followersUri(msg.getUser()))); + } note.setPublished(msg.getTimestamp()); note.setContent(MessageUtils.formatMessage(msg.getText())); if (StringUtils.isNotBlank(msg.getAttachmentType())) { diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java index c15cd8d3..61a64f8d 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java @@ -1,15 +1,11 @@ package com.juick.server.api.activity.model; -import com.juick.Message; -import com.juick.util.MessageUtils; -import org.apache.commons.lang3.StringUtils; - -import java.util.Collections; import java.util.List; public class Note extends Context { private String content; private String attributedTo; + private String inReplyTo; private Link attachment; private List to; private List cc; @@ -53,4 +49,12 @@ public class Note extends Context { public void setCc(List cc) { this.cc = cc; } + + public String getInReplyTo() { + return inReplyTo; + } + + public void setInReplyTo(String inReplyTo) { + this.inReplyTo = inReplyTo; + } } -- cgit v1.2.3