aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/api/activity
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api/activity')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/Profile.java12
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/model/OrderedCollectionPage.java10
2 files changed, 18 insertions, 4 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 ef55edf13..8072e0d3b 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
@@ -6,6 +6,7 @@ import com.juick.server.util.HttpNotFoundException;
import com.juick.server.util.UserUtils;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
+import com.juick.util.MessageUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
@@ -79,13 +80,14 @@ public class Profile {
User visitor = UserUtils.getCurrentUser();
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
- UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(baseUri);
- uriComponentsBuilder.path(String.format("/u/%s/blog", userName));
+ UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri);
+ uri.path(String.format("/u/%s/blog", userName));
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.setPublished(m.getTimestamp());
- note.setContent(m.getText());
+ note.setContent(MessageUtils.formatMessage(m.getText()));
if (StringUtils.isNotBlank(m.getAttachmentType())) {
Link attachment = new Link();
attachment.setHref(m.getAttachment().getMedium().getUrl());
@@ -96,9 +98,11 @@ public class Profile {
Person person = new Person();
person.setName(user.getName());
OrderedCollectionPage page = new OrderedCollectionPage();
+ page.setPartOf(uri.replacePath(String.format("/u/%s/blog", userName)).toUriString());
page.setId(ServletUriComponentsBuilder.fromCurrentRequestUri().toUriString());
page.setOrderedItems(notes.stream().map(a -> {
Create create = new Create();
+ create.setId(a.getId() + "#Create");
create.setActor(person);
create.setObject(a);
create.setPublished(a.getPublished());
@@ -107,7 +111,7 @@ public class Profile {
int beforeNext = mids.stream().reduce((fst, second) -> second).orElse(0);
if (beforeNext > 0) {
Link next = new Link();
- next.setHref(uriComponentsBuilder.queryParam("before", beforeNext).toUriString());
+ next.setHref(uri.queryParam("before", beforeNext).toUriString());
page.setNext(next);
}
return page;
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/OrderedCollectionPage.java b/juick-server/src/main/java/com/juick/server/api/activity/model/OrderedCollectionPage.java
index 9e03cb792..a36c6c11f 100644
--- a/juick-server/src/main/java/com/juick/server/api/activity/model/OrderedCollectionPage.java
+++ b/juick-server/src/main/java/com/juick/server/api/activity/model/OrderedCollectionPage.java
@@ -4,6 +4,8 @@ import java.util.List;
public class OrderedCollectionPage extends ActivityObject {
+ private String partOf;
+
private Link next;
private List<? extends ActivityObject> orderedItems;
@@ -23,4 +25,12 @@ public class OrderedCollectionPage extends ActivityObject {
public void setOrderedItems(List<? extends ActivityObject> orderedItems) {
this.orderedItems = orderedItems;
}
+
+ public String getPartOf() {
+ return partOf;
+ }
+
+ public void setPartOf(String partOf) {
+ this.partOf = partOf;
+ }
}