Fieldable activitypub types

Created on 22 October 2022, over 2 years ago
Updated 1 May 2025, 2 days ago

Problem/Motivation

While I was working in issue https://www.drupal.org/project/activitypub/issues/3304814 to add views to activitypub I started thinking that maybe a model change could be made. I suppose that swentel has thought about it and considered before... So maybe it's better as it's now. But it will achieve non complex way to create views automatically without working with weird relationships.

Proposed resolution

Maybe we could transform the activitypub_activity to a fieldable entity,

Maybe actors will be thought as so also.

Remaining tasks

- Change activitypub_activity models
- Change logic of how entity is obtained.

User interface changes

You will need to create an entity reference field (where you'll choose the target entity type and bundle) in each activitypub type where the reference is needed, and after creating the field you'll need to set which entityref field among the defined ones in this type will be used, That will be done in plugin settings, so plugins will point to field instead of entity type and bundle. This will allow to create views quickly and also will allow to define some plugin fields as standard fields. Also it will let to organize forms, and view modes.

Data model changes

Everything will start with something like:

diff --git a/src/Entity/ActivityPubActivity.php b/src/Entity/ActivityPubActivity.php
index 2bee09e..c705ac6 100644
--- a/src/Entity/ActivityPubActivity.php
+++ b/src/Entity/ActivityPubActivity.php
@@ -40,6 +40,7 @@ use Drupal\user\EntityOwnerTrait;
  *     },
  *   },
  *   base_table = "activitypub_activity",
+ *   data_table = "activitypub_activity_field_data",
  *   entity_keys = {
  *     "id" = "id",
  *     "label" = "id",
@@ -53,7 +54,9 @@ use Drupal\user\EntityOwnerTrait;
  *     "delete-form" = "/activitypub/{activitypub_activity}/delete",
  *     "queue" = "/activitypub/{activitypub_activity}/queue",
  *     "undo" = "/activitypub/{activitypub_activity}/undo"
- *   }
+ *   },
+ *   bundle_entity_type = "activitypub_type",
+ *   field_ui_base_route  = "entity.activitypub_type.edit_form",
  * )
  */
diff --git a/src/Entity/ActivityPubType.php b/src/Entity/ActivityPubType.php
index d30b0f5..27505be 100644
--- a/src/Entity/ActivityPubType.php
+++ b/src/Entity/ActivityPubType.php
@@ -27,6 +27,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
  *       "delete" = "Drupal\Core\Entity\EntityDeleteForm"
  *     }
  *   },
+ *   bundle_of = "activitypub_activity",
  *   config_prefix = "activitypub_type",
  *   admin_permission = "administer activitypub types",
  *   links = {
Feature request
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇪🇸Spain aleix

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024