Exemple #1
0
  @Dynamic("editor")
  public static Result removeComment(Long id) {
    final User u = Mupi.getLocalUser(session());
    final models.Profile p = u.profile;

    if (models.PubComment.find.byId(id).getProfile().getId() == p.getId()) {
      models.PubComment.uncomment(id);
      return AjaxResponse.build(0, "Cometário removido!");
    } else {
      return AjaxResponse.build(2, "Este comentário não é seu! Você não pode removê-lo");
    }
  }
Exemple #2
0
  @Restrict(Mupi.USER_ROLE)
  public static Result comment(String body, Long id) {
    final User u = Mupi.getLocalUser(session());
    final models.Profile p = u.profile;
    final models.Publication pub = models.Publication.find.byId(id);

    String safeBody =
        Jsoup.clean(
            textWithLinks(body.replaceAll("(\r\n|\n)", " <br/> ")),
            Whitelist.none().addTags("br", "a").addAttributes("a", "href", "target"));

    if (pub != null) PubComment.create(pub, p, safeBody);
    List<UserEmail> l_ue = models.Profile.emailsFromPublication(pub);
    for (UserEmail ue : l_ue) {
      if (u.getEmail().equalsIgnoreCase(ue.getEmail()))
        System.out.println("Commenter: " + ue.getEmail());
      else System.out.println(ue.getEmail());
    }
    return selectFeed(getLocalInterest(), getLocalLocation());
  }