diff options
author | Vitaly Takmazov | 2019-12-28 18:51:46 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-12-28 18:51:46 +0300 |
commit | 4c39169bee102b2bfa82b55717a3a4aa75297946 (patch) | |
tree | ac3bba2a1cb28e64f88c5334f533bd50259d8e62 /src/main/java/com/juick/server/api | |
parent | b5e946b42a07527b08b05b3e29d2795b33db9836 (diff) |
ActivityPub: fix formatting note with attachments
Diffstat (limited to 'src/main/java/com/juick/server/api')
-rw-r--r-- | src/main/java/com/juick/server/api/activity/Profile.java | 7 |
1 files changed, 3 insertions, 4 deletions
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 8e735642..9aa9dc37 100644 --- a/src/main/java/com/juick/server/api/activity/Profile.java +++ b/src/main/java/com/juick/server/api/activity/Profile.java @@ -323,8 +323,7 @@ public class Profile { String attachmentUrl = attachment.get("url"); String attachmentName = attachment.get("name"); return PlainTextFormatter.markdownUrl(attachmentUrl, attachmentName); - }).reduce((source, url) -> String.format("%s\n%s", source, url)) - .orElse(markdown); + }).reduce(markdown, (currentUrl, nextUrl) -> String.format("%s\n%s", currentUrl, nextUrl)); CommandResult result = commandsManager.processCommand( user, String.format("#%s %s", postId, commandBody), @@ -342,14 +341,14 @@ public class Profile { User user = new User(); user.setUri(URI.create(activity.getActor())); String markdown = remarkConverter.convertFragment((String)note.get("content")); + // combine note text with attachment urls String commandBody = note.get("attachment") == null ? markdown : ((List<Object>) note.get("attachment")).stream().map(attachmentObj -> { Map<String, String> attachment = (Map<String, String>) attachmentObj; String attachmentUrl = attachment.get("url"); String attachmentName = attachment.get("name"); return PlainTextFormatter.markdownUrl(attachmentUrl, attachmentName); - }).reduce((source, url) -> String.format("%s\n%s", source, url)) - .orElse(markdown); + }).reduce(markdown, (currentUrl, nextUrl) -> String.format("%s\n%s", currentUrl, nextUrl)); CommandResult result = commandsManager.processCommand( user, String.format("#%d/%d %s", reply.getMid(), reply.getRid(), commandBody), |