aboutsummaryrefslogtreecommitdiff
path: root/juick-server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/Profile.java7
-rw-r--r--juick-server/src/test/resources/create.json1
2 files changed, 6 insertions, 2 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 5328a592..b016afc9 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
@@ -287,8 +287,11 @@ public class Profile {
String postId = uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1).replace("-", "/");
User user = new User();
user.setUri(URI.create(activity.getActor()));
- Map<String, Object> attachmentObj = (Map<String, Object> )((List<Object>) note.get("attachment")).get(0);
- String attachment = note.get("attachment") != null ? (String)attachmentObj.get("url") : StringUtils.EMPTY;
+ String attachment = StringUtils.EMPTY;
+ if (note.get("attachment") != null && ((List)note.get("attachment")).size() > 0) {
+ Map<String, Object> attachmentObj = (Map<String, Object>) ((List<Object>) note.get("attachment")).get(0);
+ attachment = (String) attachmentObj.get("url");
+ }
CommandResult result = commandsManager.processCommand(user, String.format("#%s %s", postId, note.get("content")), URI.create(attachment));
logger.info(jsonMapper.writeValueAsString(result));
if (result.getNewMessage().isPresent()) {
diff --git a/juick-server/src/test/resources/create.json b/juick-server/src/test/resources/create.json
new file mode 100644
index 00000000..42d20161
--- /dev/null
+++ b/juick-server/src/test/resources/create.json
@@ -0,0 +1 @@
+{"type":"Create","id":"https://mastodon.social/users/xwatt/statuses/100850249548292153/activity","published":"2018-10-06T19:04:44Z","to":["https://www.w3.org/ns/activitystreams#Public"],"actor":"https://mastodon.social/users/xwatt","object":{"id":"https://mastodon.social/users/xwatt/statuses/100850249548292153","type":"Note","inReplyTo":"https://juick.com/m/2922602","published":"2018-10-06T19:04:44Z","url":"https://mastodon.social/@xwatt/100850249548292153","attributedTo":"https://mastodon.social/users/xwatt","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/xwatt/followers","https://juick.com/u/TJ"],"sensitive":false,"atomUri":"https://mastodon.social/users/xwatt/statuses/100850249548292153","inReplyToAtomUri":"https://juick.com/m/2922602","conversation":"tag:mastodon.social,2018-10-04:objectId=57333900:objectType=Conversation","content":"<p><span class=\"h-card\"><a href=\"https://juick.com/u/TJ\" class=\"u-url mention\">@<span>TJ</span></a></span> YO</p>","contentMap":{"en":"<p><span class=\"h-card\"><a href=\"https://juick.com/u/TJ\" class=\"u-url mention\">@<span>TJ</span></a></span> YO</p>"},"attachment":[{"type":"Document","mediaType":"image/jpeg","url":"https://files.mastodon.social/media_attachments/files/006/922/030/original/04057122ea7c6570.jpeg"}],"tag":[{"type":"Mention","href":"https://juick.com/u/TJ","name":"@TJ@juick.com"}]},"type":"Create","@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}]} \ No newline at end of file