Skip to content

Conversation

@obenland
Copy link
Member

@obenland obenland commented Dec 4, 2025

Fixes #2474

Proposed changes:

  • Add Blocklist importer class for bulk importing domain blocklists
  • Add add_site_blocks() bulk method to Moderation class for efficient imports
  • Support Mastodon CSV format (#domain header) and simple domain-per-line text files
  • Add quick-import button for IFTAS DNI list
  • Add 17 unit tests for CSV parsing

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to Tools → Import → Domain Blocklist
  • Test file upload with a CSV or TXT file containing domain names
  • Test URL import by entering a blocklist URL or clicking "Import IFTAS DNI List"
  • Verify the import complete message shows correct counts
  • Verify blocked domains appear in Settings → ActivityPub → Settings
  • Run npm run env-test -- --filter Test_Blocklist

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Add domain blocklist importer for bulk importing blocked domains.

Copilot AI review requested due to automatic review settings December 4, 2025 20:28
@obenland obenland self-assigned this Dec 4, 2025
@obenland obenland requested a review from a team December 4, 2025 20:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a domain blocklist importer feature to enable bulk importing of blocked domains from external sources. It supports multiple formats including Mastodon CSV exports and simple domain-per-line text files, with a quick-import button for the IFTAS DNI list.

Key Changes:

  • New Blocklist importer class with CSV parsing and URL import capabilities
  • Bulk add_site_blocks() method in Moderation class for efficient batch imports
  • Import UI with file upload and URL import options, including IFTAS DNI quick-import

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
includes/wp-admin/import/class-blocklist.php Core importer implementation with CSV parsing, file upload, and URL import functionality
includes/class-moderation.php Added bulk add_site_blocks() method for efficient batch domain blocking
includes/wp-admin/import/load.php Registered the blocklist importer in WordPress import system
tests/phpunit/tests/includes/wp-admin/import/class-test-blocklist.php Comprehensive test suite with 17 tests for CSV parsing edge cases
.github/changelog/2589-from-description Changelog entry for the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pfefferle
Copy link
Member

If I use an email like identifier for a domain, instead of ignoring it, the script fails completely. is @ a reserved divider in CSV?

@obenland
Copy link
Member Author

obenland commented Dec 8, 2025

If I use an email like identifier for a domain, instead of ignoring it, the script fails completely. is @ a reserved divider in CSV?

Can you help me understand where you use that? I've not been able to get beyond this:

image

@pfefferle
Copy link
Member

pfefferle commented Dec 8, 2025

When you use an email as domain in a CSV!

is @ a reserved divider in CSV?

…tests

- Add #moderation anchor to settings link for direct navigation.
- Wrap Moderation section with ID for anchor targeting.
- Add tests confirming email-like identifiers are gracefully skipped.
@obenland
Copy link
Member Author

obenland commented Dec 8, 2025

Hm, I'm unable to reproduce that. e5659cd added tests for it that succeed, too.

@obenland obenland merged commit e3220cc into trunk Dec 8, 2025
10 checks passed
@obenland obenland deleted the add/blocklist-importer branch December 8, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Bulk import blocklists

4 participants