diff options
author | Vitaly Takmazov | 2024-03-01 06:29:24 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-03-01 06:29:24 +0300 |
commit | 524290e3bfd5a9f410eef90eb723972eb9a84b3e (patch) | |
tree | 707c477977e3a4fd9c73f1883fe12ac69f99846a | |
parent | eb4acb1d7f70ddf93308f0ffc6f26c54172b206a (diff) |
ActivityPub: add missing fields to Update activities to make Mastodon happy
3 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java index c9b9822a..6837a416 100644 --- a/src/main/java/com/juick/ActivityPubManager.java +++ b/src/main/java/com/juick/ActivityPubManager.java @@ -191,10 +191,14 @@ public class ActivityPubManager implements ActivityListener, NotificationListene Actor me = conversionService.convert(user, Actor.class); Update update = new Update(); var note = makeNote(object); + var now = Instant.now(); + note.setUpdated(now); update.setId(note.getId() + "#update"); update.setActor(me.getId()); update.setObject(note); - update.setPublished(Instant.now()); + update.setPublished(now); + update.setTo(note.getTo()); + update.setCc(note.getCc()); logger.info("{} sends note update to followers", me.getId()); activityToFollowers(user, me, update); } @@ -274,6 +278,8 @@ public class ActivityPubManager implements ActivityListener, NotificationListene create.setActor(me.getId()); create.setPublished(note.getPublished()); create.setObject(note); + create.setTo(note.getTo()); + create.setCc(note.getCc()); try { activityPubService.post(me, to, create); } catch (InterruptedException | IOException | NoSuchAlgorithmException e) { diff --git a/src/main/java/com/juick/www/api/activity/model/Context.java b/src/main/java/com/juick/www/api/activity/model/Context.java index 77c1fdcb..cfcc9379 100644 --- a/src/main/java/com/juick/www/api/activity/model/Context.java +++ b/src/main/java/com/juick/www/api/activity/model/Context.java @@ -72,6 +72,7 @@ public class Context implements Serializable { private String url; private List<String> to; + private List<String> cc; private List<Context> tags; @@ -163,4 +164,12 @@ public class Context implements Serializable { public void setIcon(Image icon) { this.icon = icon; } + + public List<String> getCc() { + return cc; + } + + public void setCc(List<String> cc) { + this.cc = cc; + } } diff --git a/src/main/java/com/juick/www/api/activity/model/objects/Note.java b/src/main/java/com/juick/www/api/activity/model/objects/Note.java index 7889b172..465ad07c 100644 --- a/src/main/java/com/juick/www/api/activity/model/objects/Note.java +++ b/src/main/java/com/juick/www/api/activity/model/objects/Note.java @@ -20,6 +20,7 @@ package com.juick.www.api.activity.model.objects; import com.fasterxml.jackson.annotation.JsonFormat; import com.juick.www.api.activity.model.Context; +import java.time.Instant; import java.util.List; public class Note extends Context { @@ -30,6 +31,7 @@ public class Note extends Context { private List<String> to; private List<String> cc; private boolean sensitive; + private Instant updated; public String getContent() { return content; @@ -87,4 +89,12 @@ public class Note extends Context { public void setSensitive(boolean sensitive) { this.sensitive = sensitive; } + + public Instant getUpdated() { + return updated; + } + + public void setUpdated(Instant updated) { + this.updated = updated; + } } |