toolbox-team / reddit-moderator-toolbox

Moderator toolbox for reddit extension development.
https://www.reddit.com/r/toolbox
Apache License 2.0
114 stars 38 forks source link

Use undocumented native endpoints to leave removal reason comments/modmails #582

Closed eritbh closed 2 years ago

eritbh commented 2 years ago

this issue is written in a really roundabout way because i'm tired and have no energy sorry. but yes this is about "remove as a subreddit"

As pointed out on Discord here, there's an unoffical/undocumented native endpoint for submitting removal reasons. It allows you to send the reason as a comment under a built-in subreddit shared account (this is new and recent). I would guess it will also be used for other things in the future, e.g. to show removal reasons left on users in mod notes or something like that.

The (undocumented) endpoints are /api/v1/modactions/removal_comment_message and /api/v1/modactions/removal_link_message which take a body like

{
  "item_id": [
    "t1_ikodx0k"
  ],
  "message": "comment goes here",
  "title": "rule title goes here?",
  "type": "public_as_subreddit", // or `public`, `private`, `private_exposed`
  "lock_comment": false
}

The endpoints don't appear to require any hard link to the native removal reasons data (the "title" field is... something? but it doesn't appear to be reflected anywhere), so we should theoretically be able to modify the current Toolbox removal reasons module to use these endpoints to submit comments/modmails when leaving reasons with arbitrary text. We can also use this to support sending removal reason comments as the subreddit.

creesch commented 2 years ago

I did some testing and this should work. The only catch is that if the item isn't actually removed, the API will return a nonsense error about the ID not being correct.

creesch commented 2 years ago

Some additional thoughts:

eritbh commented 2 years ago

I think I'm in favor of replacing the existing calls with these but using our existing calls as fallbacks. As far as I can tell, the removal reasons API this is related to has been pretty stable, so I'm not terribly worried about things drastically changing. Ideally we can eventually convince Reddit to document the modactions APIs and then we can remove the fallbacks, but until then I think that makes sense to keep a fallback for what we can just in case.

creesch commented 2 years ago

Seems like a sensible approach. I am not entirely sure we can avoid using both our current endpoints and the new ones though, unless we want to take away options (and you know how well that can go over at times.

Frankly I'd be in favor of no longer offering the option to send as a personal PM. But that does leave a few other things.

So I am thinking that we might add a third radio button stating Reply through subreddit account with a comment to the item that is removed. and only use the reddit api for that to begin with. So something like this:

image

We can then trial this a bit and see how stable it is while leaving everything else as is.

Alternatively, we could do something like this:

image

And replace the entire comment action with the reddit rr api call. I am however not sure if reddit removal reasons do sticky (by default) and if they don't if the removal reason API returns the ID of the posted comment.

creesch commented 2 years ago

I just checked by monitoring network in devtools when adding a removal reason on new reddit. It appears you get the ID back of the posted removal reason. However it seems like reddit removal reasons do sticky automatically which you can't undo as it is a different account...

eritbh commented 2 years ago

god I completely forgot that we still support sending PMs as the user... I like the second option personally; splitting it up by comment actions and PM actions makes sense to me.

My perfect world scenario for removal reasons options which probably belongs in #186 and doesn't need to be considered for this issue In lieu of completely removing PM options, I might like to reorganize it so modmail and PM are separate options, the modmail choice has the "send as subreddit" toggle, and the PM option is explicitly marked as deprecated. And while we're talking about it, it'd be nice to remove "send as both" as its own option and just convert the radio buttons to checkboxes to support doing more than one thing. Ultimately something like this: - [ ] Reply with a comment - [ ] Send as /u/Sub-ModTeam/hide my username - [ ] Lock the comment - [ ] Sticky the comment - [ ] Send a modmail to the user - [ ] Send as the subreddit/hide my username - [ ] Send a personal message to the user (deprecated)
eritbh commented 2 years ago

Fixed in #583