/** * This method will return true if there are unread posts in that topic * for the current user. This state is NOT persisted and must be * explicitly set by calling Topic.setLastReadPostDate(). * <p/> * If setter has not been called this method will always return <code>true</code> * * @return if current topic has posts still unread by the current user */ public boolean isHasUpdates() { return (lastReadPostDate == null) || (lastReadPostDate.isBefore(getLastPost().getCreationDate())); }
/** * {@inheritDoc} * * <p> * The target URL has the next format http://{forum root}/posts/{id} */ @Override public String getUrlSuffix() { return URL_SUFFIX + getLastPost().getId(); }
/** * {@inheritDoc} */ @Override @PreAuthorize("hasPermission(#topic.branch.id, 'BRANCH', 'BranchPermission.VIEW_TOPICS')") public void markTopicAsRead(Topic topic) { JCUser current = userService.getCurrentUser(); if (!current.isAnonymous()) { // topics are always unread for anonymous users saveLastReadPost(current, topic, topic.getLastPost()); } }
/** * Create news item * * @param topic news topic * @param url building URL * @return item for news feed */ private Item createFeedItem(Topic topic, String url) { Item item = new Item(); Description description = new Description(); description.setType("text"); String postContent = topic.getLastPost().getPostContent(); postContent = RssUtils.skipInValidXMLChars(postContent); description.setValue(postContent); Content content = new Content(); item.setContent(content); item.setTitle(topic.getTitle()); item.setAuthor(topic.getLastPost().getUserCreated().getUsername()); item.setLink(url + "/posts/" + topic.getLastPost().getId()); item.setComments(topic.getTopicStarter().getSignature()); item.setDescription(description); item.setPubDate(topic.getModificationDate().toDate()); return item; }
/** * {@inheritDoc} */ @Override public List<Topic> fillLastReadPostForTopics(List<Topic> topics) { JCUser currentUser = userService.getCurrentUser(); if (!currentUser.isAnonymous()) { List<Topic> notModifiedTopics = extractNotModifiedTopicsSinceForumMarkedAsRead( currentUser, topics); for (Topic notModifiedTopic : notModifiedTopics) { Post lastPost = notModifiedTopic.getLastPost(); notModifiedTopic.setLastReadPostDate(lastPost.getCreationDate()); } // @SuppressWarnings("unchecked") List<Topic> modifiedTopics = ListUtils.removeAll(topics, notModifiedTopics); fillLastReadPostsForModifiedTopics(modifiedTopics, currentUser); } return topics; }