Esempio n. 1
0
  /**
   * Follow notification.
   *
   * @param id the id of the notification.
   */
  public static void followNotification(int id) {
    User user = Session.user();
    Notification notification = user.getNotification(id);
    if (notification != null) {
      notification.unsetNew();
      Entry about = notification.getAbout();

      if (about instanceof Answer) {
        ActionDefinition action = reverse();
        Answer answer = (Answer) about;
        Application.question(answer.getQuestion().id());
        redirect(action.addRef("answer-" + answer.id()).toString());
      } else if (about instanceof Question) {
        Application.question(((Question) about).id());
      } else if (about instanceof Comment) {
        ActionDefinition action = reverse();
        Comment comment = (Comment) about;
        Application.question(comment.getQuestion().id());
        redirect(action.addRef("comment-" + comment.id()).toString());
      }
    } else if (!redirectToCallingPage()) {
      Application.notifications(0);
    }
  }