aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java7
-rw-r--r--src/main/java/com/juick/service/activities/UpdateEvent.java13
-rw-r--r--src/main/java/com/juick/www/api/Post.java2
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java2
4 files changed, 13 insertions, 11 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java
index 4324df11..1fff41fc 100644
--- a/src/main/java/com/juick/ActivityPubManager.java
+++ b/src/main/java/com/juick/ActivityPubManager.java
@@ -161,16 +161,17 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
@Override
public void processUpdateEvent(UpdateEvent event) {
- String objectUri = event.getMessageUri();
+ Message object = event.getMessage();
User user = event.getUser();
Actor me = conversionService.convert(user, Actor.class);
socialService.getFollowers(user).forEach(acct -> {
try {
Actor follower = (Actor) signatureManager.getContext(URI.create(acct)).orElseThrow();
Update update = new Update();
- update.setId(objectUri + "#update");
+ var note = makeNote(object);
+ update.setId(note.getId() + "#update");
update.setActor(me.getId());
- update.setObject(new Context(objectUri));
+ update.setObject(note);
logger.info("Update to follower {}", follower.getId());
signatureManager.post(me, follower, update);
} catch (IOException | NoSuchAlgorithmException e) {
diff --git a/src/main/java/com/juick/service/activities/UpdateEvent.java b/src/main/java/com/juick/service/activities/UpdateEvent.java
index c5cceb24..879d8005 100644
--- a/src/main/java/com/juick/service/activities/UpdateEvent.java
+++ b/src/main/java/com/juick/service/activities/UpdateEvent.java
@@ -17,31 +17,32 @@
package com.juick.service.activities;
+import com.juick.model.Message;
import com.juick.model.User;
import org.springframework.context.ApplicationEvent;
public class UpdateEvent extends ApplicationEvent {
private final User actor;
- private final String messageUri;
+ private final Message message;
/**
* Create a new {@code ApplicationEvent}.
*
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
* @param actor the event author
- * @param messageUri the object's id
+ * @param message the object
*/
- public UpdateEvent(Object source, User actor, String messageUri) {
+ public UpdateEvent(Object source, User actor, Message message) {
super(source);
this.actor = actor;
- this.messageUri = messageUri;
+ this.message = message;
}
public User getUser() {
return actor;
}
- public String getMessageUri() {
- return messageUri;
+ public Message getMessage() {
+ return message;
}
}
diff --git a/src/main/java/com/juick/www/api/Post.java b/src/main/java/com/juick/www/api/Post.java
index 63c95f2a..c840a590 100644
--- a/src/main/java/com/juick/www/api/Post.java
+++ b/src/main/java/com/juick/www/api/Post.java
@@ -237,7 +237,7 @@ public class Post {
messagesService.getMessage(mid).orElseThrow(IllegalStateException::new)
: messagesService.getReply(mid, rid);
applicationEventPublisher.publishEvent(
- new UpdateEvent(this, author, profileUriBuilder.messageUri(mid, rid)));
+ new UpdateEvent(this, author, result));
return CommandResult.build(result, "Message updated", StringUtils.EMPTY);
}
throw new HttpBadRequestException();
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 1e40ee6e..89c3b089 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1489,7 +1489,7 @@ public class ServerTests {
Mockito.verify(activityListener, Mockito.times(1)).onApplicationEvent(updateEventCaptor.capture());
UpdateEvent updateEvent = updateEventCaptor.getValue();
assertThat(updateEvent.getUser(), is(ugnich));
- assertThat(profileUriBuilder.messageUri(original.getMid(), 0), is(updateEvent.getMessageUri()));
+ assertThat(original.getMid(), is(updateEvent.getMessage().getMid()));
mockMvc.perform(post("/api/update").with(httpBasic(freefdName, freefdPassword))
.param("mid", String.valueOf(original.getMid())).param("body", "PEOPLE"))
.andExpect(status().is(403));