Ejemplo n.º 1
0
  @Audit
  @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
  @Override
  public void reportSpammersContent(User spammer, User reporter, String comment) {
    if (log.isInfoEnabled()) {
      log.info(
          "Reporting SPAM Abuse on all content of of this spammer: "
              + spammer.getUsername()
              + ". Reporter is: "
              + reporter.getUsername());
    }

    final Date reportDate = new Date();

    Iterable<Document> docs = documentManager.getUserDocuments(spammer, documentStates);
    for (Document document : docs) {
      if (log.isTraceEnabled()) {
        log.trace("Report spam of document: " + document.getDocumentID());
      }
      reportSpam(document, reporter, comment, reportDate);
    }

    Iterable<ForumMessage> messages = forumManager.getUserMessages(spammer);
    for (ForumMessage message : messages) {
      if (log.isTraceEnabled()) {
        log.trace(
            "Report spam of message: "
                + message.getID()
                + ", threadId: "
                + message.getForumThreadID());
      }
      // TODO: Check how works root messages (threads)
      reportSpam(message, reporter, comment, reportDate);
    }

    List<Blog> blogs = blogManager.getExplicitlyEntitledBlogs(spammer);
    for (Blog blog : blogs) {
      if (blog.isUserBlog()) {
        Iterator<BlogPost> blogPosts = blogManager.getBlogPosts(blog);
        while (blogPosts.hasNext()) {
          BlogPost blogPost = blogPosts.next();
          if (log.isTraceEnabled()) {
            log.trace("Report spam for Blog post, id: " + blogPost.getID());
          }
          reportSpam(blogPost, reporter, comment, reportDate);
        }
      }
    }
    Iterator<Favorite> favorites =
        favoriteManager.getUserFavorites(spammer, Sets.newHashSet(externalUrlObjectType));
    while (favorites.hasNext()) {
      Favorite favorite = favorites.next();
      JiveObject favoritedObject = favorite.getObjectFavorite().getFavoritedObject();
      if (log.isTraceEnabled()) {
        log.trace("Report spam Favorite (Bookmark) to external URL: " + favorite.getID());
        log.trace("Favorited object: " + favoritedObject);
      }
      reportSpam(favoritedObject, reporter, comment, reportDate);
    }
  }
Ejemplo n.º 2
0
  @Override
  public boolean hasSomeContent(User author, JiveContentObject newObject) {

    ModerationHelper moderationHelper = JiveApplication.getContext().getModerationHelper();

    // Note: hasSomeContent expects its interceptor to be TYPE_POST (called
    // AFTER creating a content),
    // thus a number of existing content on time of creating a first content
    // is always one.

    // check for Messages and Threads (root discussions and questions):
    int messagesCount = forumManager.getUserMessageCount(author);
    log.info("hasSomeContent Messages size: " + messagesCount);

    // moderation-safe message addition:
    // for each user-added message check whether the message is moderated
    // if all found messages are moderated, send a new content to moderation
    if (messagesCount > 0) {
      for (ForumMessage m : forumManager.getUserMessages(author)) {

        // forumManager.getUserMessages() also returns message being
        // inserted when triggering interceptor
        if (!moderationHelper.isInModeration(m) && !m.equals(newObject)) {
          if (log.isDebugEnabled()) {
            log.debug(
                "message "
                    + m.getPlainSubject()
                    + " does not equal to the message to be inserted and is not moderated: returns true");
          }
          return true;
        }
      }
    }

    // check for documents
    int documentsCount = documentManager.getUserDocumentCount(author, documentStates);
    log.info("hasSomeContent: Documents size: " + documentsCount);

    // moderation-safe edition: similar to messages
    if (documentsCount >= 1) {
      for (Document d : documentManager.getUserDocuments(author, documentStates)) {
        if (!moderationHelper.isInModeration(d) && d.getID() != newObject.getID()) {
          if (log.isDebugEnabled()) {
            log.debug(
                "document: "
                    + d.getPlainSubject()
                    + "is not the document to be inserted and is not moderated: hasSomeContent returns true");
          }
          return true;
        }
      }
    }

    // check for blogposts:
    // Note: Blogpost edit does not trigger interceptor
    for (Blog b : blogManager.getExplicitlyEntitledBlogs(author)) {
      if (b.getContributors().contains(author)) {

        Iterator<BlogPost> blogIterator = blogManager.getBlogPosts(b);
        while (blogIterator.hasNext()) {
          BlogPost existingPost = blogIterator.next();

          if (existingPost.getID() != newObject.getID()
              && !moderationHelper.isInModeration(existingPost)) {
            if (log.isDebugEnabled()) {
              log.debug(
                  "hasSomeContent: Blog size > 0: "
                      + existingPost.getSubject()
                      + " is not moderated and is not the one being inserted: hasSomeContent returns true");
            }
            return true;
          }
        }
      }
    }
    log.debug("hasSomeContent: Blog size: 0");

    // Types not triggering interceptor, thus not considered:
    // Poll, File, Task, Bookmark, Status update

    return false;
  }
Ejemplo n.º 3
0
  @Audit
  @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
  @Override
  public void resolveContentAsSpam(User spammer, User moderator) {
    if (log.isInfoEnabled()) {
      log.info("Resolve SPAM reports on all content of of this user: "******"Resolve Documents");
    Iterable<Document> docs = documentManager.getUserDocuments(spammer, documentStatesToResolve);
    for (Document document : docs) {
      if (log.isTraceEnabled()) {
        log.trace("Resolve Report spam of document: " + document.getDocumentID());
      }
      resolveSpamReport(document, moderator);
    }

    log.debug("Resolve Threads");
    ThreadResultFilter moderationFilter = ThreadResultFilter.createDefaultUserMessagesFilter();
    moderationFilter.setStatus(JiveContentObject.Status.ABUSE_HIDDEN);

    Iterable<ForumMessage> messages = forumManager.getUserMessages(spammer, moderationFilter);
    List<Long> resolvedThreads = new ArrayList<Long>();

    for (ForumMessage message : messages) {
      if (log.isTraceEnabled()) {
        log.trace(
            "Resolve Report spam of message: "
                + message.getID()
                + ", threadId: "
                + message.getForumThreadID());
      }
      ForumThread thread = message.getForumThread();
      if (!resolvedThreads.contains(thread.getID())) {
        resolvedThreads.add(thread.getID());
        if (thread.getUser().getUsername().equals(spammer.getUsername())) {
          if (log.isTraceEnabled()) {
            log.trace("Resolve Report spam of thread: " + thread.getID());
          }
          resolveSpamReport(thread, moderator);
        }
      }
      resolveSpamReport(message, moderator);
    }

    log.debug("Resolve Blogs");
    Iterable<Blog> blogs = blogManager.getExplicitlyEntitledBlogs(spammer);
    for (Blog blog : blogs) {
      if (log.isTraceEnabled()) {
        log.trace("Processing blog: " + blog.getName());
      }
      if (blog.isUserBlog()) {
        Iterator<BlogPost> blogPosts = getBlogPosts(blog, JiveContentObject.Status.ABUSE_HIDDEN);
        while (blogPosts.hasNext()) {
          BlogPost blogPost = blogPosts.next();
          if (log.isTraceEnabled()) {
            log.trace("Resolve Report spam Blog post: " + blogPost.getID());
          }
          resolveSpamReport(blogPost, moderator);
        }
      }
    }

    log.trace("Resolve Bookmarks");
    Iterator<Favorite> favorites =
        favoriteManager.getUserFavorites(spammer, Sets.newHashSet(externalUrlObjectType));
    while (favorites.hasNext()) {
      Favorite favorite = favorites.next();
      JiveObject favoritedObject = favorite.getObjectFavorite().getFavoritedObject();
      if (log.isTraceEnabled()) {
        log.trace("Resolve Report spam Favorite (Bookmark) to external URL: " + favorite.getID());
        log.trace(
            "Favorited object, id: "
                + favoritedObject.getID()
                + ", type: "
                + favoritedObject.getObjectType());
      }
      resolveSpamReport(favoritedObject, moderator);
    }
  }