Skip to content

Fix ModNote.fromProto to map modActionData to modAction#269

Open
hsource wants to merge 4 commits into
reddit:mainfrom
hsource:fix/modnote-map-modaction-data
Open

Fix ModNote.fromProto to map modActionData to modAction#269
hsource wants to merge 4 commits into
reddit:mainfrom
hsource:fix/modnote-map-modaction-data

Conversation

@hsource

@hsource hsource commented Jun 21, 2026

Copy link
Copy Markdown

Motivation

While writing a moderation app that auto-applies escalating bans, I realized that the modAction wasn't actually being converted from the proto.

In my app, I worked around this by directly calling getDevvitConfig().use(ModNoteDefinition);, which is a bit of a hack, so I wanted to resolve this more permanently with this upstream PR.

Changes

  • Introduce ModNoteAction — a focused type with action, redditId, details, and description — instead of reusing the full ModAction type
  • Map modActionData inline in ModNote.#fromProto for both @devvit/reddit and @devvit/public-api
  • Parse redditId with typed ID helpers (asTID / asTid) for T1/T2/T3 fullnames
  • Document details and description for banuser actions (duration like "1 days", ban reasoning)
  • Update mod note API tests to assert the slimmer modAction shape

Testing

I couldn't really test this unfortunately since the root README.md instructions failed at the point I tried to yarn to install, since there were many Reddit-internal packages whose installs didn't work even after I disabled artifactory. I did do a thorough self-review of the PR though and its logic looks pretty simple

  • yarn workspace @devvit/reddit test:unitgetModNotes() maps modActionData to modAction test
  • yarn workspace @devvit/public-api test:unit — same test in public-api package
  • Manual: call reddit.getModNotes({ subreddit, user, filter: 'MOD_ACTION' }) and verify ban notes include modAction.details and modAction.description

reddit.getModNotes() already receives modActionData from the Reddit API,
but #fromProto never populated modAction on the returned ModNote objects.
Map action, details, description, and target redditId so callers can read
ban/removal/approval metadata without bypassing the client.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hsource hsource requested a review from a team as a code owner June 21, 2026 09:23
hsource and others added 3 commits June 21, 2026 02:57
Introduce a focused ModNoteAction type instead of reusing ModAction, and map modActionData inline in fromProto with typed redditId conversion.

Co-authored-by: Cursor <cursoragent@cursor.com>
Explain that mod notes and moderation log entries are distinct use cases with overlapping context already on ModNote.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore the original UserNote shape, userNote optional typing, and inline createdAt conversion.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant