Skip to content

Commit

Permalink
added a couple of new webhook events - question.approve and answer.ap…
Browse files Browse the repository at this point in the history
…prove to trigger when a mod approves a post
  • Loading branch information
albogdano committed Jun 21, 2024
1 parent 598f45a commit 36a5838
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,17 @@ public String modApprove(@PathVariable String id, HttpServletRequest req) {
if (utils.isMod(authUser)) {
if (showPost instanceof UnapprovedQuestion) {
showPost.setType(Utils.type(Question.class));
showPost.setApprovedby(authUser);
pc.create(showPost);
// this notification here is redundant
//utils.sendNewPostNotifications(showPost, req);
utils.triggerHookEvent("question.approve", showPost);
} else if (showPost instanceof UnapprovedReply) {
showPost.setType(Utils.type(Reply.class));
showPost.setApprovedby(authUser);
addRepOnReplyOnce(pc.read(showPost.getParentid()), (Profile) pc.read(showPost.getCreatorid()), true);
pc.create(showPost);
utils.triggerHookEvent("answer.approve", showPost);
}
utils.deleteReportsAfterModAction(showPost);
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/erudika/scoold/core/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public abstract class Post extends Sysprop {

private transient Profile author;
private transient Profile lastEditor;
private transient Profile approvedby;
private transient List<Comment> comments;
private transient Pager itemcount;
private transient Vote vote;
Expand All @@ -108,6 +109,14 @@ public void setApprovalTimestamp(Long approvalTimestamp) {
this.approvalTimestamp = approvalTimestamp;
}

public Profile getApprovedby() {
return approvedby;
}

public void setApprovedby(Profile approvedby) {
this.approvedby = approvedby;
}

public Boolean getDeprecated() {
if (deprecated == null || isReply()) {
deprecated = false;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/erudika/scoold/utils/ScooldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ public final class ScooldUtils {
"question.create",
"question.close",
"question.view",
"question.approve",
"answer.create",
"answer.accept",
"answer.approve",
"report.create",
"comment.create",
"user.signin",
Expand Down

0 comments on commit 36a5838

Please sign in to comment.