diff options
author | 2018-09-05 15:41:25 +0300 | |
---|---|---|
committer | 2018-09-05 15:41:25 +0300 | |
commit | 2f972edbba5e37499982b017e51d1d7c471f2307 (patch) | |
tree | 7d126cbe0a53fc063bfe8ffbcfea785f52afc392 /juick-server/src/main/java/com | |
parent | 9b7d2f44f705830602d1ff4612cc8780c8188aa7 (diff) |
ActivityStreams: to, attributedTo
Diffstat (limited to 'juick-server/src/main/java/com')
3 files changed, 29 insertions, 1 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 8072e0d3..a0804d2c 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 @@ -17,6 +17,7 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder; import javax.inject.Inject; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -81,11 +82,15 @@ public class Profile { User user = userService.getUserByName(userName); if (!user.isAnonymous()) { UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); - uri.path(String.format("/u/%s/blog", userName)); + String blogUri = uri.path(String.format("/u/%s/blog/toc", userName)).toUriString(); + String followersUri = uri.path(String.format("/u/%s/followers/toc", userName)).toUriString(); 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(blogUri); + note.setTo(Arrays.asList(followersUri, + "https://www.w3.org/ns/activitystreams#Public")); note.setPublished(m.getTimestamp()); note.setContent(MessageUtils.formatMessage(m.getText())); if (StringUtils.isNotBlank(m.getAttachmentType())) { @@ -103,6 +108,7 @@ public class Profile { page.setOrderedItems(notes.stream().map(a -> { Create create = new Create(); create.setId(a.getId() + "#Create"); + create.setTo(a.getTo()); create.setActor(person); create.setObject(a); create.setPublished(a.getPublished()); diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Create.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Create.java index 8d81b26b..60ad4ae3 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Create.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Create.java @@ -1,9 +1,12 @@ package com.juick.server.api.activity.model; +import java.util.List; + public class Create extends ActivityObject { private Person actor; private Note object; + private List<String> to; public Person getActor() { return actor; @@ -20,4 +23,12 @@ public class Create extends ActivityObject { public void setObject(Note object) { this.object = object; } + + public List<String> getTo() { + return to; + } + + public void setTo(List<String> to) { + this.to = to; + } } diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java index ae799f5e..8a34c926 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Note.java @@ -1,9 +1,12 @@ package com.juick.server.api.activity.model; +import java.util.List; + public class Note extends ActivityObject { private String content; private String attributedTo; private Link attachment; + private List<String> to; public String getContent() { return content; @@ -28,4 +31,12 @@ public class Note extends ActivityObject { public void setAttachment(Link attachment) { this.attachment = attachment; } + + public List<String> getTo() { + return to; + } + + public void setTo(List<String> to) { + this.to = to; + } } |