Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add "report" button to document viewer to report abuse #997

Merged
merged 13 commits into from
Oct 16, 2024
Merged

feat: Add "report" button to document viewer to report abuse #997

merged 13 commits into from
Oct 16, 2024

Conversation

RajuGangitla
Copy link
Contributor

I added a report button to report the inappropriate content. i have give some options to select and submit. It will the save the details in redis and viewer can report one time for one document

Fixes #812

@mfts

@RajuGangitla RajuGangitla requested a review from mfts as a code owner October 15, 2024 04:52
Copy link

vercel bot commented Oct 15, 2024

@RajuGangitla is attempting to deploy a commit to the mftsio Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Owner

@mfts mfts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good. Just some small performance and UI improvements :)

pages/api/report.ts Show resolved Hide resolved
Comment on lines 47 to 63
// Add the viewId to the Redis set for this documentId and linkId
await redis.sadd(reportKey, viewId);

// Increment the report count for the documentId and linkId
const updatedCount = await redis.hincrby(
"reportCounts",
`${documentId}:${linkId}`,
1
);

// Store the abuse type report under a Redis hash for future analysis
await redis.hset(
`report:${documentId}:${linkId}:details`,
{
[viewId]: abuseType // Store the abuseType as a number for this viewId
}
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can put these three await calls into a Promise.all to parallelize it as they are not dependent on each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfts resolved both

Comment on lines 64 to 113
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
<DialogTrigger asChild>
<Button
className="m-1 bg-gray-900 text-white hover:bg-gray-900/80"
size="icon"
title="Report abuse"
>
<Flag className="h-5 w-5" />
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Report an Issue</DialogTitle>
<DialogDescription>
What kind of issue would you like to report? Please select the most appropriate option.
</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<RadioGroup onValueChange={setAbuseType} className="grid gap-2">
<div className="flex items-center space-x-2">
<RadioGroupItem value="spam" id="spam" />
<Label htmlFor="spam">Spam, Fraud, or Scam</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="malware" id="malware" />
<Label htmlFor="malware">Malware or virus</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="copyright" id="copyright" />
<Label htmlFor="copyright">Copyright violation</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="harmful" id="harmful" />
<Label htmlFor="harmful">Harmful content</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="not-working" id="not-working" />
<Label htmlFor="not-working">Content is not working properly</Label>
</div>
<div className="flex items-center space-x-2">
<RadioGroupItem value="other" id="other" />
<Label htmlFor="other">Other</Label>
</div>
</RadioGroup>
</div>
<DialogFooter>
<Button onClick={handleSubmit} disabled={!abuseType}>Submit Report</Button>
</DialogFooter>
</DialogContent>
</Dialog>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a Dialog, let's make it a Popover, it feels more clean in this case

https://ui.shadcn.com/docs/components/popover

RajuGangitla and others added 2 commits October 16, 2024 05:05
commit 2a29305
Author: Marc Seitz <[email protected]>
Date:   Wed Oct 16 18:47:50 2024 +0900

    refactor: change redis keys for better clarify

    - move flag button around
Copy link
Owner

@mfts mfts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Copy link

vercel bot commented Oct 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
papermark ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2024 10:04am

@RajuGangitla
Copy link
Contributor Author

@mfts can I work on the other issues that people are assigned but didnt raise pull request for more than a week ?

@mfts mfts merged commit 9af1596 into mfts:main Oct 16, 2024
2 checks passed
Copy link

oss-gg bot commented Oct 16, 2024

Awarding RajuGangitla: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/RajuGangitla

@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🕹️] Add "report" button to document viewer to report abuse
2 participants