activitypub icon indicating copy to clipboard operation
activitypub copied to clipboard

Allow users to opt in/out of ActivityPub

Open nedjo opened this issue 6 years ago • 3 comments

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:

activitypub_user_field

Tasks

  • [ ] Provide a field storage, field_activitypub_user, of type boolean. Set locked and persist_with_no_fields to true.
  • [ ] Provide a field using this storage on the user bundle of the user entity.
  • [ ] In hook_form_FORM_ID_alter() for user_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

nedjo avatar Dec 20 '19 19:12 nedjo

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.

swentel avatar Dec 21 '19 13:12 swentel

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).

ekes avatar Jan 11 '20 13:01 ekes

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.

swentel avatar Aug 20 '20 17:08 swentel