Skip to content

Skip Reddit submissions with removal metadata - #255

Open
xbloodyknight wants to merge 2 commits into
Fillll:masterfrom
xbloodyknight:fix/skip-removed-submissions
Open

xbloodyknight wants to merge 2 commits into
Fillll:masterfrom
xbloodyknight:fix/skip-removed-submissions

Conversation

@xbloodyknight

Copy link
Copy Markdown

Problem

The bot sent this removal notice to @rStableDiffusion https://t.me/rStableDiffusion/67954:

Removed by Reddit

Removed by Reddit on account of violating the [content policy. ]

Reported post: https://redd.it/1wiuyhz

send_simple has no check if the post is removed. A removal notice could therefore reach the existing text-sending code.

Change

Add this guard before score checks and URL processing:

if getattr(submission, 'removed_by_category', None):
    return SupplyResult.DO_NOT_WANT_THIS_SUBMISSION

Remaining uncertainty

This should catch the reported post if Reddit provides removal metadata, but I couldn't confirm that without API credentials. @Fillll , could you verify this?

Why this should work in theory

PRAW's own recorded Data API response from May 2025 contains:

"removed_by_category": null

This directly confirms that the API PRAW uses returns this field and that it can be null. Python decodes JSON null as None.

PRAW exposes attributes returned by Reddit dynamically, so the guard reads the response field directly.

Reddit's removal-category documentation describes nonempty categories for removals, including content_takedown, copyright_takedown, moderator, and deleted. This documentation describes Devvit, rather than PRAW's Data API, so it supports the interpretation of removal categories but does not independently prove the Data API response for the reported post.

The reasoning is that a Reddit removal notice should carry a nonempty removal category. If it does, this guard rejects the submission before any sending code runs. The exact category does not matter because the guard accepts any truthy value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant