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

Expose report categories via API #30301

Open
ThisIsMissEm opened this issue May 14, 2024 · 5 comments
Open

Expose report categories via API #30301

ThisIsMissEm opened this issue May 14, 2024 · 5 comments
Labels
suggestion Feature suggestion

Comments

@ThisIsMissEm
Copy link
Contributor

Pitch

Currently many clients do not implement the correct categorization of Reports that are created, generally only allowing reporting of rule violations. I suspect this is because there's no API through which to request back the report categories which are defined as an enum on the Report model.

We could either expose just the enum key (which is used for subsequent requests), or we could localise the response (category, title, description).

Motivation

Having the report categories available via API would enable clients to dynamically display the report categories, and allow picking from those, and then if the category is "violation" then show the "rule violated selector" UI.

This should improve reports received from Mobile apps.

@ThisIsMissEm ThisIsMissEm added the suggestion Feature suggestion label May 14, 2024
@ThisIsMissEm
Copy link
Contributor Author

An initial draft implementation exists in #30300

@nikclayton
Copy link

AIUI, the report categories are enumerated in the API description for https://docs.joinmastodon.org/methods/reports/#post.

Although that documentation appears to be out of date, as it lists 4 categories, and performing a test report through the web UI shows 5 categories.

Would updating the documentation solve this specific case?

Is supporting a general "A server might introduce it's own report categories, and clients should be able to discover what those are and show localised UI text" a different problem?

@ThisIsMissEm
Copy link
Contributor Author

ThisIsMissEm commented May 14, 2024

@nikclayton it's actually correct!

it lists 4 categories, and performing a test report through the web UI shows 5 categories.

The top option "I just don't like this" is not really a report category, it's a fake option that takes you to block/mute options:

IMG_7664

There's only legal, spam, violation and other; violation is only present if the instance has rules to violate.

(Though there's certainly interest in more categories! And we have added categories over time as required)

Is supporting a general "A server might introduce it's own report categories, and clients should be able to discover what those are and show localised UI text" a different problem?

It's in this discussion. See the PR I linked, or the issue description.

If we want the server to give a user-localised response, it can't be in the instance info endpoint (which is public / cached), so we'd need a new endpoint somewhere for it.

@cheeaun
Copy link
Contributor

cheeaun commented May 15, 2024

Exposing these from the API would be useful.

Here's how it looks like now on Phanpy:
Screenshot 2024-05-15 at 9 07 05 AM

  • Highlighted sections to visually emphasize some parts are from API, some are hard-coded client-side.
  • The server rule violations list "depends" on the violation reason.
  • Localization would be a concern as mentioned above.

@VyrCossont
Copy link
Contributor

VyrCossont commented May 15, 2024

For further reference, here's Feditext's report screen. Feditext fetches the server software name and version from the NodeInfo doc, and has a hardcoded list of which Mastodon-like servers support which report API parameters, including which report categories are supported. This list has to be updated periodically, every time Mastodon adds a category (or Feditext adds support for another Mastodon-like server). Rules are pulled from the instance itself and displayed when the violation category is selected. (If there are no instance rules, violation isn't offered as an option.)

Feditext report screen showing category radio button, rules checkboxes, reason text field, forwarding toggle, and list of posts

Just listing report category enum values won't help much. If I want to show anything other than the raw enum value, I still need to know what the possible values are (from Mastodon API docs) when I ship the app so I can localize strings for them ahead of time, or I need to be able to get localized values in my app locale from the instance server.

It'd be only middlingly useful to have an API to fetch both a list of acceptable category enum values and their localized names in a requested locale. If categories don't change that often, it's actually more work to fetch and cache the results of a report categories API endpoint than it is to use my existing localization mechanisms and update whenever Mastodon updates the report endpoint. Version rules are unfortunately already a necessity when dealing with the Mastodon API.

However, the category and localized name API would be necessary if you're planning on allowing admins to customize the list of accepted categories. It'd also be good for the API ecosystem, since it offers a way for Mastodon forks or Mastodon-compatible servers to extend the list of categories.

It'd be even more useful to be able to get localized versions of instance-specific strings. @ThisIsMissEm brought up instance rules as one example; I'd also like to be able to get a localized instance description or extended description, and localized role names. Localized supported posting languages and supported translation languages would also be handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Feature suggestion
Projects
None yet
Development

No branches or pull requests

4 participants