Skip to content

Commit

Permalink
forum allows mature words for mature topics
Browse files Browse the repository at this point in the history
  • Loading branch information
Varrience authored Jan 4, 2025
1 parent cb93668 commit bfb8289
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions API/Forum/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ notifyUserFollowers(title,user,content,link) {
}

async publish(req, res, next) {
req.body = JSON.parse(Profanity.censorText(JSON.stringify(req.body)));
req.body = req.body.mature ? req.body: JSON.parse(Profanity.censorText(JSON.stringify(req.body)));
var { title, content, tags, mature, hidden, privateRecipients } = req.body;
console.log(title,content);
try {
Expand Down Expand Up @@ -88,7 +88,7 @@ async publish(req, res, next) {
}

async update(req, res, next) {
req.body = JSON.parse(Profanity.censorText(JSON.stringify(req.body)));
req.body = req.body.mature ? req.body: JSON.parse(Profanity.censorText(JSON.stringify(req.body)));
var { title, content, tags, mature, hidden, privateRecipients } = req.body;
console.log(title,content);
try {
Expand Down Expand Up @@ -284,8 +284,6 @@ async unfeature(req, res, next) {

async comment(req, res, next) {
var { content } = req.body;
content = Profanity.censorText(content);
console.log(content);
try {
const pid = req.params.id;
const post = await this.model.findOne({ _id: pid });
Expand All @@ -301,6 +299,7 @@ async comment(req, res, next) {
});
post.activeAt = Date.now();
post.viewers = [];
content = post.mature ? content: Profanity.censorText(content)
post.comments.push({
content,
rating: 0,
Expand Down Expand Up @@ -375,7 +374,6 @@ async deleteComment(req, res, next) {

async editComment(req, res, next) {
var { content, index } = req.body;
content = Profanity.censorText(content);
console.log(content,index);
try {
const pid = req.params.id;
Expand All @@ -392,6 +390,7 @@ async editComment(req, res, next) {
});
post.activeAt = Date.now();
post.viewers = [];
content = post.mature ? content: Profanity.censorText(content)
comment.content = content;
await post.save();
res.status(201).json({
Expand Down

0 comments on commit bfb8289

Please sign in to comment.