コード例 #1
0
ファイル: DbSpamManager.java プロジェクト: jbossorg/sbs-spam
  @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);
    }
  }
コード例 #2
0
ファイル: DbSpamManager.java プロジェクト: jbossorg/sbs-spam
  @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);
    }
  }