aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/api/activity/Profile.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api/activity/Profile.java')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/Profile.java36
1 files changed, 11 insertions, 25 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java
index 656d85dd..7b854d52 100644
--- a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java
+++ b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java
@@ -1,6 +1,7 @@
package com.juick.server.api.activity;
import com.juick.User;
+import com.juick.server.ActivityPubManager;
import com.juick.server.KeystoreManager;
import com.juick.server.SignatureManager;
import com.juick.server.api.activity.model.*;
@@ -43,6 +44,8 @@ public class Profile {
@Inject
private SignatureManager signatureManager;
@Inject
+ private ActivityPubManager activityPubManager;
+ @Inject
private ApplicationEventPublisher applicationEventPublisher;
@Value("${web_domain:localhost}")
private String domain;
@@ -55,11 +58,9 @@ public class Profile {
public Person getUser(@PathVariable String userName) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
- UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
Person person = new Person();
- uri.replacePath(String.format("/u/%s", userName));
- person.setId(uri.toUriString());
- person.setUrl(uri.toUriString());
+ person.setId(activityPubManager.personUri(user));
+ person.setUrl(activityPubManager.personUri(user));
person.setName(userName);
person.setPreferredUsername(userName);
Key publicKey = new Key();
@@ -67,11 +68,10 @@ public class Profile {
publicKey.setOwner(person.getId());
publicKey.setPublicKeyPem(keystoreManager.getPublicKeyPem());
person.setPublicKey(publicKey);
- uri.replacePath("/api/inbox");
- person.setInbox(uri.toUriString());
- person.setOutbox(uri.replacePath(String.format("/u/%s/blog/toc", userName)).toUriString());
- person.setFollowers(uri.replacePath(String.format("/u/%s/followers/toc", userName)).toUriString());
- person.setFollowing(uri.replacePath(String.format("/u/%s/following/toc", userName)).toUriString());
+ person.setInbox(activityPubManager.inboxUri());
+ person.setOutbox(activityPubManager.outboxUri(user));
+ person.setFollowers(activityPubManager.followersUri(user));
+ person.setFollowing(activityPubManager.followingUri(user));
UriComponentsBuilder image = UriComponentsBuilder.fromUriString(baseImagesUri);
image.path(String.format("/a/%d.png", user.getUid()));
Image avatar = new Image();
@@ -103,23 +103,9 @@ public class Profile {
if (!user.isAnonymous()) {
UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
String personUri = uri.path(String.format("/u/%s", userName)).toUriString();
- String followersUri = uri.replacePath(String.format("/u/%s/followers/toc", userName)).toUriString();
+ String followersUri = activityPubManager.followersUri(user);
List<Integer> mids = messagesService.getUserBlog(user.getUid(), 0, before);
- List<Note> notes = messagesService.getMessages(visitor, mids).stream().map(m -> {
- Note note = new Note();
- note.setId(uri.replacePath(String.format("/m/%d", m.getMid())).toUriString());
- note.setAttributedTo(personUri);
- note.setTo(Collections.singletonList("https://www.w3.org/ns/activitystreams#Public"));
- note.setCc(Collections.singletonList(followersUri));
- note.setPublished(m.getTimestamp());
- note.setContent(MessageUtils.formatMessage(m.getText()));
- if (StringUtils.isNotBlank(m.getAttachmentType())) {
- Link attachment = new Link();
- attachment.setHref(m.getAttachment().getMedium().getUrl());
- note.setAttachment(attachment);
- }
- return note;
- }).collect(Collectors.toList());
+ List<Note> notes = messagesService.getMessages(visitor, mids).stream().map(activityPubManager::makeNote).collect(Collectors.toList());
Person person = new Person();
person.setName(user.getName());
OrderedCollectionPage page = new OrderedCollectionPage();