aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/server/ActivityPubManager.java11
-rw-r--r--src/main/java/com/juick/server/CommandsManager.java8
-rw-r--r--src/main/java/com/juick/server/api/activity/Profile.java9
3 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/com/juick/server/ActivityPubManager.java b/src/main/java/com/juick/server/ActivityPubManager.java
index 2fa663eb..76ab677a 100644
--- a/src/main/java/com/juick/server/ActivityPubManager.java
+++ b/src/main/java/com/juick/server/ActivityPubManager.java
@@ -15,6 +15,7 @@ import com.juick.server.api.activity.model.objects.Image;
import com.juick.server.api.activity.model.objects.Mention;
import com.juick.server.api.activity.model.objects.Note;
import com.juick.server.api.activity.model.objects.Person;
+import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.HttpUtils;
import com.juick.service.MessagesService;
import com.juick.service.SocialService;
@@ -355,4 +356,14 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
}
});
}
+ public User personToUser(URI uri) throws HttpBadRequestException {
+ Person person = (Person) signatureManager.getContext(uri).orElseThrow(HttpBadRequestException::new);
+ User user = new User();
+ user.setUri(URI.create(person.getId()));
+ user.setName(person.getPreferredUsername());
+ if (person.getIcon() != null) {
+ user.setAvatar(person.getIcon().getUrl());
+ }
+ return user;
+ }
}
diff --git a/src/main/java/com/juick/server/CommandsManager.java b/src/main/java/com/juick/server/CommandsManager.java
index 6fd88f07..598772f1 100644
--- a/src/main/java/com/juick/server/CommandsManager.java
+++ b/src/main/java/com/juick/server/CommandsManager.java
@@ -84,6 +84,8 @@ public class CommandsManager {
private ImagesService imagesService;
@Inject
private WebApp webApp;
+ @Inject
+ private ActivityPubManager activityPubManager;
public CommandResult processCommand(@Nonnull User user, String data, @Nonnull URI attachment) throws Exception {
if (!user.isAnonymous()) {
@@ -566,7 +568,11 @@ public class CommandsManager {
Message original = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new);
subscriptionService.subscribeMessage(original, user);
Message reply = messagesService.getReply(mid, newrid);
- reply.getUser().setAvatar(webApp.getAvatarUrl(reply.getUser()));
+ if (reply.getUser().isAnonymous()) {
+ reply.setUser(activityPubManager.personToUser(reply.getUser().getUri()));
+ } else {
+ reply.getUser().setAvatar(webApp.getAvatarUrl(reply.getUser()));
+ }
applicationEventPublisher.publishEvent(
new SystemEvent(this,
SystemActivity.message(reply.getUser(), reply,
diff --git a/src/main/java/com/juick/server/api/activity/Profile.java b/src/main/java/com/juick/server/api/activity/Profile.java
index 0f258770..77945d6b 100644
--- a/src/main/java/com/juick/server/api/activity/Profile.java
+++ b/src/main/java/com/juick/server/api/activity/Profile.java
@@ -390,13 +390,6 @@ public class Profile {
}
@PostMapping(value = "/u/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public User fetchUser(@RequestParam URI uri) {
- Person person = (Person) signatureManager.getContext(uri).orElseThrow(HttpBadRequestException::new);
- User user = new User();
- user.setUri(URI.create(person.getId()));
- user.setName(person.getPreferredUsername());
- if (person.getIcon() != null) {
- user.setAvatar(person.getIcon().getUrl());
- }
- return user;
+ return activityPubManager.personToUser(uri);
}
}