-
Notifications
You must be signed in to change notification settings - Fork 811
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
Conversation
@RajuGangitla is attempting to deploy a commit to the mftsio Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this 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
Outdated
// 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 | ||
} | ||
); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfts resolved both
components/view/report-form.tsx
Outdated
<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> |
There was a problem hiding this comment.
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@mfts can I work on the other issues that people are assigned but didnt raise pull request for more than a week ? |
Awarding RajuGangitla: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/RajuGangitla |
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