Skip to content

Commit

Permalink
fix: wait until report is received by Natty if a red flag will be raised
Browse files Browse the repository at this point in the history
  • Loading branch information
double-beep authored Jul 26, 2024
1 parent 334db3f commit fe8438b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/UserscriptTools/NattyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface NattyFeedbackItem {
}

export class NattyAPI extends Reporter {
public raisedRedFlag = false;

private static nattyIds: number[] = [];

private readonly chat: ChatApi = new ChatApi();
Expand Down Expand Up @@ -115,7 +117,11 @@ export class NattyAPI extends Reporter {
// - when a mod flags a post as NAA/VLQ it is deleted immediately.
// - when a reviewer sends the last Recommend deletion/Delete review,
// the post is also deleted immediately
if (StackExchange.options.user.isModerator || Page.isLqpReviewPage) {
// - if a red flag has been raised by the user
if (StackExchange.options.user.isModerator
|| Page.isLqpReviewPage
|| this.raisedRedFlag
) {
// init websocket
const url = await this.chat.getFinalUrl();
const wsUtils = new WebsocketUtils(url, this.id, this.progress);
Expand Down
5 changes: 5 additions & 0 deletions src/UserscriptTools/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ export default class Post {
console.log('Post', this.id, 'manually flagged as', flag, flagType);
}

const natty = this.reporters.Natty;
if (natty) {
natty.raisedRedFlag = ['PostSpam', 'PostOffensive'].includes(flag);
}

await addProgress(event, flagType, this);
$(this.flagged).fadeIn();
}, { once: true });
Expand Down
5 changes: 5 additions & 0 deletions src/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ export class Popover {
this.post.progress = new Progress(controller);
this.post.progress.attach();

const natty = this.post.reporters.Natty;
if (natty) {
natty.raisedRedFlag = reportType === FlagNames.Spam || reportType === FlagNames.Rude;
}

// if feedback is sent successfully, the success variable is true, otherwise false
const success = await this.post.sendFeedbacks(flagType);

Expand Down

0 comments on commit fe8438b

Please sign in to comment.