Commits

Shihab Hamid committed 0b2c908

replies of retweets now link to the retweet instead of the original tweet

Comments (0)

Files changed (2)

src/main/java/com/atlascamp/mywork/tweets/TweetsActionService.java

     {
         Twitter twitter = new TwitterFactory().getInstance();
 
-        String globalId = action.path("globalId").getValueAsText();
-        long tweetId = Long.parseLong(globalId.replace("tweet:", ""));
-
         String qualifiedAction = action.path("qualifiedAction").getValueAsText();
         String entityAction = qualifiedAction.replace(getApplication() + ".tweet.", "");
 
         if (entityAction.equals("retweet"))
         {
+            String globalId = action.path("globalId").getValueAsText();
+            long tweetId = Long.parseLong(globalId.replace("tweet:", ""));
             try
             {
                 twitter.retweetStatus(tweetId);
         {
             String replyTweet = action.path("comment").getValueAsText();
             String userHandle = action.path("metadata").path("user").getValueAsText();
+            Long tweetId = Long.parseLong(action.path("metadata").path("originalTweetId").getValueAsText());
 
             String fullReply = userHandle + " " + replyTweet;
             fullReply = StringUtils.abbreviate(fullReply, 140);

src/main/java/com/atlascamp/mywork/tweets/TwitterListener.java

                 .itemUrl("http://twitter.com/" + status.getUser().getScreenName() + "/status/" + status.getId())
                 .itemIconUrl("https://twitter.com/images/resources/twitter-bird-16x16.png")
                 .iconUrl(status.getUser().getProfileImageURL().toString())
-                .metadata(createMetadata("user", "@" + status.getUser().getScreenName()));
+                .metadata(createMetadata("@" + status.getUser().getScreenName(), status.getId()));
 
         // is it an original tweet or a re-tweet?
         if (status.getRetweetedStatus() != null)
         notificationService.createOrUpdate("admin", notification);
     }
 
-    private ObjectNode createMetadata(String key, String val)
+    private ObjectNode createMetadata(String user, long tweetId)
     {
         ObjectNode metadata = JsonNodeFactory.instance.objectNode();
-        metadata.put(key, val);
+        metadata.put("user", user);
+        metadata.put("originalTweetId", String.valueOf(tweetId));
         return metadata;
     }