mastodon/app/controllers/admin
Matt Jankowski 4fa462a9f8 Extract form batch classes for relationships and follow recommendations
Related to - https://github.com/mastodon/mastodon/pull/35458 - which added a batch base class, and to - https://github.com/mastodon/mastodon/pull/35872 - which envisions a world where form objects tell the view what to do.

Background here...

- The `Form::AccountBatch` form object is used in a few different places, for somewhat varied purposes
- The user relationships view uses it on a show page, which does a PUT to update, and uses the `follow`, `unfollow`, `remove_from_followers`, and `remove_domains_from_followers` "actions" of the form model
- The admin accounts view shows a form on index view, does POST to batch action, uses the `suspend`, `approve` and `reject` actions.
- The admin relationships view (for admins only) also has a form on index and does a POST back to that same spot
- The admin/follow_recommendations page has a form on show and does PUT to update, using the `suppress_follow_recommendation` and `unsuppress_follow_recommendation` actions

So, while these are all related in that they supply an `accounts_ids` array, the actual things that they "bulk update" are Follow (from relationships), FollowRecommendationSuppression (from follow recs) and Account (from accounts). This is a little inconsistent with other of the "batch form model" classes, which tend to update the same domain concept (ie, CustomEmojiBlock, IpBlockBatch, EmailDomainBlockBatch, etc) that they are named after (and in some cases that a "filter" class is named after).

All that said, the changes here:

- Pull out `Form::FollowRecommendationBatch` and `Form::RelationshipBatch` classes, which more closely align with the domain concept they are bulk updating (open to naming suggestions here)
- Mark both of these as `persisted?` true so that their form views will infer correct HTTP action
- Add some missing coverage to existing class, and coverage for new classes as well

It would be pretty straightforward to chop this up into smaller pieces, if any of "just the coverage first", "just the boolean attribute", "one new batch class at a time", etc - were more appealing.

Possible follow-up:

- In the existing `Form::AccountBatch`, use attributes API for boolean `select_all_matching` value, remove query method
- Convert the relationships controller spec to mix of request/system specs, round out coverage
- Most (all maybe?) of the "batch actions" are doing a `POST` to a `batch` action on the controller of whatever they are related to. Might be worth looking at what the diff would look like to move these all to nested controllers where they did a `PUT to */batches#update` with restful routing, etc.
2025-08-25 10:31:37 -04:00
..
announcements Add ability to email announcements to all users (#33928) 2025-03-06 14:05:27 +00:00
disputes Fix wrong policy authorization in admin controllers (#35588) 2025-07-30 13:17:53 +00:00
fasp Basic FASP support (#34031) 2025-03-28 12:16:40 +00:00
instances Implement Instance Moderation Notes (#31529) 2025-06-25 08:15:44 +00:00
reports Move shared params to common method in admin/reports/actions (#35353) 2025-07-14 09:23:18 +00:00
settings
terms_of_service Add effective date to terms of service (#33993) 2025-03-05 09:01:33 +00:00
trends Limit count to pending&trending on admin/trends/tags page (#35120) 2025-06-23 13:30:12 +00:00
users Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
webhooks
account_actions_controller.rb Fix error handling for blank actions in account moderation action form (#35246) 2025-07-03 14:42:48 +00:00
account_moderation_notes_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
accounts_controller.rb Combine assignment params in admin/accounts#batch action (#35463) 2025-07-23 07:59:14 +00:00
action_logs_controller.rb Sort auditable accounts (#35272) 2025-07-30 15:08:05 +00:00
announcements_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
base_controller.rb Remove duplicate cache header setting before action (#33833) 2025-02-05 09:19:08 +00:00
change_emails_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
confirmations_controller.rb Set flash options via redirect where possible (#35370) 2025-07-24 08:03:28 +00:00
custom_emojis_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
dashboard_controller.rb Use async count in admin dashboard (#30606) 2024-09-06 16:52:35 +00:00
domain_allows_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
domain_blocks_controller.rb Fix wrong policy authorization in admin controllers (#35588) 2025-07-30 13:17:53 +00:00
email_domain_blocks_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
export_domain_allows_controller.rb File cleanup/organization in controllers/concerns (#27846) 2023-11-30 14:39:41 +00:00
export_domain_blocks_controller.rb Add specs for Instance model scopes and add with_domain_follows scope (#28767) 2024-01-25 15:28:27 +00:00
follow_recommendations_controller.rb Extract form batch classes for relationships and follow recommendations 2025-08-25 10:31:37 -04:00
instances_controller.rb Implement Instance Moderation Notes (#31529) 2025-06-25 08:15:44 +00:00
invites_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
ip_blocks_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
relationships_controller.rb
relays_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
report_notes_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
reports_controller.rb Fix sort order of moderation notes on Reports and Accounts (#31528) 2024-09-06 14:58:36 +00:00
resets_controller.rb
roles_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
rules_controller.rb Change rule translation interface to display english name and populate empty translations (#35170) 2025-06-25 10:02:19 +00:00
settings_controller.rb Set flash options via redirect where possible (#35370) 2025-07-24 08:03:28 +00:00
site_uploads_controller.rb Redirect back after site upload deletion (#30141) 2024-05-06 13:31:39 +00:00
software_updates_controller.rb Fix Mastodon listing updates older or equal to current version (#33906) 2025-02-12 14:27:42 +00:00
statuses_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
tags_controller.rb Use report_range method in admin/tags to generate reporting period (#35465) 2025-07-23 08:02:07 +00:00
terms_of_service_controller.rb Add effective date to terms of service (#33993) 2025-03-05 09:01:33 +00:00
username_blocks_controller.rb Add ability to block words in usernames (#35407) 2025-07-29 10:19:15 +00:00
warning_presets_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00
webhooks_controller.rb Use expect for admin/ controllers (#33686) 2025-01-27 14:05:16 +00:00