Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom-dependency-tree.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ai.elimu:webapp:war:2.6.139-SNAPSHOT
ai.elimu:webapp:war:2.6.140-SNAPSHOT
+- ai.elimu:model:jar:model-2.0.124:compile
| \- com.google.code.gson:gson:jar:2.13.1:compile
| \- com.google.errorprone:error_prone_annotations:jar:2.38.0:compile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import ai.elimu.util.DiscordHelper.Channel;
import ai.elimu.util.DomainHelper;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;

Expand All @@ -23,6 +24,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -110,10 +112,17 @@ public String handleSubmit(
@ResponseBody
public String handleAddContentLabelRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@PathVariable Long id) {
log.info("handleAddContentLabelRequest");

Contributor contributor = (Contributor) session.getAttribute("contributor");
if (contributor == null) {
response.setStatus(HttpStatus.FORBIDDEN.value());
return "error";
}

log.info("id: " + id);
Emoji emoji = emojiDao.read(id);

Expand All @@ -129,7 +138,7 @@ public String handleAddContentLabelRequest(
emojiDao.update(emoji);

EmojiContributionEvent emojiContributionEvent = new EmojiContributionEvent();
emojiContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
emojiContributionEvent.setContributor(contributor);
emojiContributionEvent.setTimestamp(Calendar.getInstance());
emojiContributionEvent.setEmoji(emoji);
emojiContributionEvent.setRevisionNumber(emoji.getRevisionNumber());
Expand All @@ -145,10 +154,17 @@ public String handleAddContentLabelRequest(
@ResponseBody
public String handleRemoveContentLabelRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@PathVariable Long id) {
log.info("handleRemoveContentLabelRequest");

Contributor contributor = (Contributor) session.getAttribute("contributor");
if (contributor == null) {
response.setStatus(HttpStatus.FORBIDDEN.value());
return "error";
}

log.info("id: " + id);
Emoji emoji = emojiDao.read(id);

Expand All @@ -169,7 +185,7 @@ public String handleRemoveContentLabelRequest(
emojiDao.update(emoji);

EmojiContributionEvent emojiContributionEvent = new EmojiContributionEvent();
emojiContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
emojiContributionEvent.setContributor(contributor);
emojiContributionEvent.setTimestamp(Calendar.getInstance());
emojiContributionEvent.setEmoji(emoji);
emojiContributionEvent.setRevisionNumber(emoji.getRevisionNumber());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ai.elimu.util.GitHubLfsHelper;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.File;
Expand All @@ -44,6 +45,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -253,15 +255,20 @@ protected void initBinder(HttpServletRequest request, ServletRequestDataBinder b
@ResponseBody
public String handleAddContentLabelRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@PathVariable Long id) {
log.info("handleAddContentLabelRequest");

Contributor contributor = (Contributor) session.getAttribute("contributor");
if (contributor == null) {
response.setStatus(HttpStatus.FORBIDDEN.value());
return "error";
}

log.info("id: " + id);
Image image = imageDao.read(id);

Contributor contributor = (Contributor) session.getAttribute("contributor");

String letterIdParameter = request.getParameter("letterId");
log.info("letterIdParameter: " + letterIdParameter);
if (StringUtils.isNotBlank(letterIdParameter)) {
Expand Down Expand Up @@ -332,15 +339,20 @@ public String handleAddContentLabelRequest(
@ResponseBody
public String handleRemoveContentLabelRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@PathVariable Long id) {
log.info("handleRemoveContentLabelRequest");

Contributor contributor = (Contributor) session.getAttribute("contributor");
if (contributor == null) {
response.setStatus(HttpStatus.FORBIDDEN.value());
return "error";
}

log.info("id: " + id);
Image image = imageDao.read(id);

Contributor contributor = (Contributor) session.getAttribute("contributor");

String letterIdParameter = request.getParameter("letterId");
log.info("letterIdParameter: " + letterIdParameter);
if (StringUtils.isNotBlank(letterIdParameter)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import ai.elimu.util.GitHubLfsHelper;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
Expand All @@ -36,6 +37,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -185,10 +187,17 @@ protected void initBinder(HttpServletRequest request, ServletRequestDataBinder b
@ResponseBody
public String handleAddContentLabelRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@PathVariable Long id) {
log.info("handleAddContentLabelRequest");

Contributor contributor = (Contributor) session.getAttribute("contributor");
if (contributor == null) {
response.setStatus(HttpStatus.FORBIDDEN.value());
return "error";
}

log.info("id: " + id);
Video video = videoDao.read(id);

Expand All @@ -204,7 +213,7 @@ public String handleAddContentLabelRequest(
videoDao.update(video);

VideoContributionEvent videoContributionEvent = new VideoContributionEvent();
videoContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
videoContributionEvent.setContributor(contributor);
videoContributionEvent.setTimestamp(Calendar.getInstance());
videoContributionEvent.setVideo(video);
videoContributionEvent.setRevisionNumber(video.getRevisionNumber());
Expand All @@ -225,7 +234,7 @@ public String handleAddContentLabelRequest(
videoDao.update(video);

VideoContributionEvent videoContributionEvent = new VideoContributionEvent();
videoContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
videoContributionEvent.setContributor(contributor);
videoContributionEvent.setTimestamp(Calendar.getInstance());
videoContributionEvent.setVideo(video);
videoContributionEvent.setRevisionNumber(video.getRevisionNumber());
Expand All @@ -246,7 +255,7 @@ public String handleAddContentLabelRequest(
videoDao.update(video);

VideoContributionEvent videoContributionEvent = new VideoContributionEvent();
videoContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
videoContributionEvent.setContributor(contributor);
videoContributionEvent.setTimestamp(Calendar.getInstance());
videoContributionEvent.setVideo(video);
videoContributionEvent.setRevisionNumber(video.getRevisionNumber());
Expand All @@ -262,10 +271,17 @@ public String handleAddContentLabelRequest(
@ResponseBody
public String handleRemoveContentLabelRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
@PathVariable Long id) {
log.info("handleRemoveContentLabelRequest");

Contributor contributor = (Contributor) session.getAttribute("contributor");
if (contributor == null) {
response.setStatus(HttpStatus.FORBIDDEN.value());
return "error";
}

log.info("id: " + id);
Video video = videoDao.read(id);

Expand All @@ -286,7 +302,7 @@ public String handleRemoveContentLabelRequest(
videoDao.update(video);

VideoContributionEvent videoContributionEvent = new VideoContributionEvent();
videoContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
videoContributionEvent.setContributor(contributor);
videoContributionEvent.setTimestamp(Calendar.getInstance());
videoContributionEvent.setVideo(video);
videoContributionEvent.setRevisionNumber(video.getRevisionNumber());
Expand All @@ -311,7 +327,7 @@ public String handleRemoveContentLabelRequest(
videoDao.update(video);

VideoContributionEvent videoContributionEvent = new VideoContributionEvent();
videoContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
videoContributionEvent.setContributor(contributor);
videoContributionEvent.setTimestamp(Calendar.getInstance());
videoContributionEvent.setVideo(video);
videoContributionEvent.setRevisionNumber(video.getRevisionNumber());
Expand All @@ -336,7 +352,7 @@ public String handleRemoveContentLabelRequest(
videoDao.update(video);

VideoContributionEvent videoContributionEvent = new VideoContributionEvent();
videoContributionEvent.setContributor((Contributor) session.getAttribute("contributor"));
videoContributionEvent.setContributor(contributor);
videoContributionEvent.setTimestamp(Calendar.getInstance());
videoContributionEvent.setVideo(video);
videoContributionEvent.setRevisionNumber(video.getRevisionNumber());
Expand Down
Loading