Allow users to opt in/out of ActivityPub
This could look something like the "Personal contact form" fieldset provided by Drupal core.
While, instead of a field, we could use the same approach as in the Contact module - providing data to be serialized into the user.data store, that old-school approach has various drawbacks including limiting the ability to query.
UI
Fieldset on user profile edit form:

Tasks
- [ ] Provide a field storage,
field_activitypub_user, of typeboolean. Setlockedandpersist_with_no_fieldsto true. - [ ] Provide a field using this storage on the
userbundle of theuserentity. - [ ] In
hook_form_FORM_ID_alter()foruser_settings_form, wrap our field in "Fediverse" fieldset - Make ActivityPub functionality conditional on field value
- [ ] Availability of user inbox and outbox
- [ ] Visibility of other UI elements
- On toggle of field value
- [ ] Present confirmation page warning of data changes
- [ ] Delete existing ActivityPub data for the user
On thing that came to mind for this issue after reading #4 is whether this fieldset should also contain a textfield where you configure the unique fediverse name. e.g. you can enter swentel or nedjo and perform some validation on it:
- no spaces
- no weird chars
- no duplicates
Another option is to derive this automatically from the drupal user name, but it should be sanitized as well.
Note: I'm not a 100% what the exact constraints are for a unique name.
So this was something I found solved by doing the separate actor entity as outlined in https://socialhub.activitypub.rocks/t/a-quick-survey-of-php-projects-in-the-activitypub-space-plus-comments/464/2
That way both users and groups in this case can enable their AP by creating the related actor entity by choosing their unique @name. In cases where there are only users and no other actor types obviously this could be defaulted to a checkbox that creates the entity with the username as the @name (the generation of the entity then auto generates the pub/priv key, has the hook for webfinger, and enables routes for inbox, outbox and so forth).
I've committed the first code on drupal.org, yay!
Instead of a field, I went for a form alter service which has a method to add a form element to enable and configure a unique name. This is stored in a simple Activity Actor entity type. Looks like a good approach so far, and it should be easy to add 'group' and other types as well.
No pub/priv keys etc yet, the commit only focused on the alter and the param converter tested on one route (being the inbox).
Feedback - and patches :) - welcome of course.