/** * Determines whether a given tweet is a retweet made by the current user. Twitter's API really is unhelpful on this * side so we mostly take an educated guess here, although it should be enough in most cases. * * @param status the tweet to test against * * @return true if and only if the given status is a retweet made by the current user */ public boolean isRetweetByCurrentUser(final Status status) { if (status.isRetweet()) { final Status retweetedStatus = status.getRetweetedStatus(); return retweetedStatus.isRetweeted() || retweetedStatus.isRetweetedByMe() || sessionManager.isCurrentUser(status.getUser()); } else { return false; } }
@Override public void initialize() { setUpInteractionActions(); targetStatus.addListener((o, prev, cur) -> { updateRetweetVisual(cur.isRetweet() ? cur.getRetweetedStatus().isRetweeted() : cur.isRetweeted()); updateLikeVisual(cur.isFavorited()); }); }
for (Status status : statuses) { boolean hasMedia = status.getMediaEntities().length > 0; if (hasMedia && !status.isRetweet()) { for (MediaEntity mediaEntity : status.getMediaEntities()) { photos.add(
.put("Retweeted", status.isRetweeted()) .put("FavoriteCount", status.getFavoriteCount()) .put("Retweet", status.isRetweet()) .put("RetweetCount", status.getRetweetCount()) .put("RetweetedByMe", status.isRetweetedByMe())
/** * Checks whether a given tweet has been retweeted by the current user. * <p> * PSA : I don't care that you can retweet your own tweets. This is stupid and you should never do it. Will never * allow a PR "fixing" that pass. * * @param tweet the tweet to check * * @return Whether the given tweet had not yet been retweeted by the current user. */ public boolean notYetRetweeted(final Status tweet) { return !sessionManager.doWithCurrentTwitter(twitter -> { final Status updatedTweet = twitter.showStatus(tweet.getId()); final Status originalStatus = updatedTweet.isRetweet() ? updatedTweet.getRetweetedStatus() : updatedTweet; return originalStatus.isRetweeted(); }).get(); }
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
ResponseList<Status> tweets = twitter.getHomeTimeline(); for(Status s : tweets){ Tweet temp; if(s.isRetweet()){ temp = new Tweet(s.getRetweetedStatus(),s.getUser().getName()); } else{ temp = new Tweet(s); } tweetsPanel.add(temp); tweetsPanel.add(Box.createRigidArea(new Dimension(0,2))); }
/** * @param newValue The status to prepare displaying for. */ @Override public void updateWithValue(final Status newValue) { if (newValue == null || this.currentStatus.getValue() == newValue) { return; } this.currentStatus.setValue(newValue); this.isRetweet.set(currentStatus.getValue().isRetweet()); authorProfilePicture.setImage(GENERAL_USER_AVATAR_DARK.getImage()); if (currentStatus.getValue().isRetweet()) { handleRetweet(currentStatus.getValue()); } else { setStatusDisplay(currentStatus.getValue()); } }
long userId = status.getUser().getId(); long tweetId = status.getId(); long resolvedTweetId = status.isRetweet() ? status.getRetweetedStatus().getId() : status.getId(); HashtagEntity[] hashtagEntities = status.getHashtagEntities();
/** * Unretweets (deletes the retweet-created tweet for the current user. See {@link #retweet(Status)} for explanation * on that). * * @param tweet the tweet to unretweet * * @return The retweet that was deleted */ Status unretweet(final Status tweet) { final Status original = tweet.isRetweet() ? tweet.getRetweetedStatus() : tweet; return sessionManager.doWithCurrentTwitter( twitter -> twitter.unRetweetStatus(original.getId()) ).onSuccess(resultingStatus -> LOG.debug( "User {} unretweeted tweet {}", getCurrentScreenName(), resultingStatus.getId() )).onFailure(err -> displayExceptionPane( "Could not unretweet tweet!", err.getMessage(), err )).get(); }
/** * Called on click of the retweet button. * <p> * Will call {@link #updateRetweetVisual(boolean)} on task finish to set the appropriate visual value. * * @see TwitterInteractionService * @see TwitterBinaryInteraction * @see StatusInteraction#RETWEET */ private void onRetweet() { LOG.debug("Retweet interaction on status {}", targetStatus.getValue().getId()); retweetButton.setDisable(true); CompletableFuture.supplyAsync( () -> interactionService.interact(targetStatus.getValue(), RETWEET) ).thenAcceptAsync(res -> { final Status originalStatus = targetStatus.getValue().isRetweet() ? targetStatus.getValue().getRetweetedStatus() : targetStatus.getValue(); updateRetweetVisual(!interactionService.notYetRetweeted(originalStatus)); retweetButton.setDisable(false); }, Platform::runLater); }
log.info(String.format("@%s - %s", name, statusText)); try { if (status.isRetweet()) { if (user.isDropRetweets()) { user.setLatestId(status.getId());
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }