aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r--juick-server/src/main/java/com/juick/server/ActivityPubManager.java33
1 files changed, 23 insertions, 10 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 49895bc8..e590f4f9 100644
--- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
+++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
@@ -38,13 +38,6 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
@Value("${ap_base_uri:http://localhost:8080/}")
private String baseUri;
- private UriComponentsBuilder uri;
-
- @PostConstruct
- public void init() {
- uri = UriComponentsBuilder.fromUriString(baseUri);
- }
-
@Override
public void processFollowEvent(@Nonnull FollowEvent followEvent) {
String acct = (String)followEvent.getRequest().getObject();
@@ -132,32 +125,52 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
}
public String inboxUri() {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
return uri.replacePath("/api/inbox").toUriString();
}
public String outboxUri(User user) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
return uri.replacePath(String.format("/u/%s/blog/toc", user.getName())).toUriString();
}
public String personUri(User user) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
return uri.replacePath(String.format("/u/%s", user.getName())).toUriString();
}
public String followersUri(User user) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
return uri.replacePath(String.format("/u/%s/followers/toc", user.getName())).toUriString();
}
public String followingUri(User user) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
return uri.replacePath(String.format("/u/%s/following/toc", user.getName())).toUriString();
}
+ public String messageUri(Message msg) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
+ uri.replacePath(String.format("/m/%d", msg.getMid()));
+ if (MessageUtils.isReply(msg)) {
+ uri.fragment(String.valueOf(msg.getRid()));
+ }
+ return uri.toUriString();
+ }
+ public String messageUri(int mid, int rid) {
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
+ uri.replacePath(String.format("/m/%d", mid));
+ if (rid > 0) {
+ uri.fragment(String.valueOf(rid));
+ }
+ return uri.toUriString();
+ }
public Note makeNote(Message msg) {
Note note = new Note();
- note.setId(uri.replacePath(String.format("/m/%d", msg.getMid())).toUriString());
+ note.setId(messageUri(msg));
note.setAttributedTo(personUri(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());
+ note.setInReplyTo(messageUri(msg.getMid(), msg.getReplyto()));
}
if (MessageUtils.isPM(msg)) {
note.setTo(Collections.singletonList(activityPubManager.personUri(msg.getTo())));