aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-04 13:25:34 +0300
committerGravatar Vitaly Takmazov2018-10-04 13:25:34 +0300
commitfdc329f367e5685cc9d4b0654f53eaa03818e905 (patch)
treedee8b3c8a693d910df8bb86f5f65345518de1049
parentd4fc7a5dc48a37facb8381a8eca90e659e11ca31 (diff)
AcitvityPub: correct addressing for replies and pms
-rw-r--r--juick-server/src/main/java/com/juick/server/ActivityPubManager.java12
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/model/Note.java14
2 files changed, 19 insertions, 7 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 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<FollowEvent>, 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<String> to;
private List<String> cc;
@@ -53,4 +49,12 @@ public class Note extends Context {
public void setCc(List<String> cc) {
this.cc = cc;
}
+
+ public String getInReplyTo() {
+ return inReplyTo;
+ }
+
+ public void setInReplyTo(String inReplyTo) {
+ this.inReplyTo = inReplyTo;
+ }
}