diff options
author | Vitaly Takmazov | 2018-10-06 22:24:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-06 22:29:31 +0300 |
commit | 4b7702d846c281459433cf51dab5669fb3466b12 (patch) | |
tree | 03213221cec8ecab194d36b2b582ecc691445abe /juick-server/src/main/java/com | |
parent | 6de186c9712311e5205187ca99ebb24c342e0a5f (diff) |
fix index out of bounds
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/activity/Profile.java | 7 |
1 files changed, 5 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()) { |