LangCorrect / server

Master grammar, spelling, and syntax in the language(s) you’re learning through direct feedback on your writing from fluent, native speakers.
https://langcorrect.com
22 stars 12 forks source link

[WIP] Report System #210

Closed danielzeljko closed 5 days ago

danielzeljko commented 9 months ago

Reportable Objects

Report Reasons for Posts

Report Reasons for Profiles

Report Reasons for Corrections

Notes

Report app

Models (WIP/TBD)

itshesam commented 8 months ago

I'm not sure of what you meant by if we should have a single field for reason or break them apart for each reportable object, but it seems that we should have a separate model for each reportable object and we probably want to have a field for the type of report to be able to query on reports based on that.

Instead of is_expired we probably need an expiration_timestamp as it gives us more control over the things that we can do based on that.

danielzeljko commented 8 months ago

I've included your suggestion for an expiration timestamp. Thanks for the feedback! I'm still not sure how I should handle the ReportReasons. I can use two different tables for this so that we can have different reasons depending on the object type (ie: post, corrections), but it just seems like an overkill for our application. The current approach is a lot simpler and we can just exclude malicious corrections for everything other than corrections.

Here's what I am currently sitting on (not finalized):

class ReportReasons(models.TextChoices):
    # general
    SPAM = "spam", _("Spam")
    OTHER = "other", _("Other")
    INAPPROPRIATE_CONTENT = "inappropriate_content", _("Inappropriate Content")

    # corrections
    MALICIOUS_CORRECTION = "malicious_correction", _("Malicious Correction")

class Report(SoftDeletableModel, TimeStampedModel):
    sender = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="reports_sent")
    receiver = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="reports_received")

    reason = models.CharField(
        max_length=50,
        choices=ReportReasons.choices,
        # default=ReportReasons.OTHER,
    )

    post = models.ForeignKey("posts.Post", on_delete=models.CASCADE, null=True, blank=True)
    profile = models.ForeignKey("users.User", on_delete=models.CASCADE, null=True, blank=True)
    correction = models.ForeignKey("corrections.CorrectedRow", on_delete=models.CASCADE, null=True, blank=True)

class Infraction(SoftDeletableModel, TimeStampedModel):
    report = models.OneToOneField(Report, on_delete=models.CASCADE, related_name="infraction")
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="infractions")
    expires_at = models.DateTimeField(
        # lambdas can't be used because they can't be serialized by migrations
        default=get_expiration_date
    )

    @property
    def is_expired(self):
        return timezone.now() >= self.expires_at
itshesam commented 8 months ago

I think these models that you introduced are enough and complete for our purposes. I didn't get why you thought that this is an overkill. There was only a couple of things that I noticed. First the user in Infraction may be redundant, and second we may want to have an index on reason field to be able to search on that, but it can be added later if needed.

danielzeljko commented 8 months ago

By overkill, I meant to have additional tables like ReportReasons and ReportCategories (ie: post, correction, profile, etc), so that we can have different reasons depending on the report object.

dgunay commented 4 months ago

Does the report button not do anything yet? I noticed a post by a user that breaks the community guidelines and was curious about the reporting process. Clicking the Report button on their profile doesn't appear to do anything.

danielzeljko commented 4 months ago

No it doesn't do anything at the moment and it should have been commented out.

Edit: Can you send a report to support@langcorrect.com in the meantime?

dgunay commented 4 months ago

No it doesn't do anything at the moment and it should have been commented out.

Edit: Can you send a report to support@langcorrect.com in the meantime?

I didn't feel the post was made with ill intent (navigating unfamiliar cultures is challenging and it's easy to come across as rude in your non-native languages) so I didn't actually want to report it, I was just curious about what the process looked like and what information went along with it so that's why I clicked on it.