Rendering inbox activities

Created on 1 May 2025, 1 day ago

Problem/Motivation

Just to better understand it and related to the issue: https://www.drupal.org/project/activitypub/issues/3508103 📌 Allow like/announce not having to map to entities Active : I am trying to create a view with inbox activities, and I can do some theme processing from payload property by now... But to better understand the module logic; the mapping works with dynamictypes to create outbox activity from a node, and with the comment to create comment entities from inbox. But there is no plugin that translates an Inbox Create activity to a node. True?
Do you think that will be useful, a way to render non comment inbox (like "Create") activities? Or in this use case a new plugin to process inbox activities to nodes will make more sense ?

If it is fine to use the payload, thene we can also add a hook_theme to render activities and let users do the theme processing from payload and all the activity properties...

🌱 Plan
Status

Active

Version

1.0

Component

Code

Created by

🇪🇸Spain aleix

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

Merge Requests

Comments & Activities

  • Issue created by @aleix
  • 🇪🇸Spain aleix

    Just dropping the simple rendering of entity (with payload) as node (in 10.5) does.

  • 🇧🇪Belgium swentel

    Do you think that will be useful, a way to render non comment inbox (like "Create") activities? Or in this use case a new plugin to process inbox activities to nodes will make more sense ?

    I think it's very useful to have rendering of this out of the box!
    Currently, I'm using the reader module to view all incoming activities, but this should be possible with this module too.

    Not a fan to create nodes from these though. I think we can use a viewBuilder class and than use inspiration from Reader::buildMicrosubItem to render inbox activities, and maybe have different templates depending on some logic: e.g. Inbox -> like template, Inbox -> Create template, Inbox -> Announce template, Inbox -> Follow template and a 'default' one which does something clever with the payload although I have no idea what yet :)

    The view builder class should split rendering between inbox and outbox, especially when 📌 Allow like/announce not having to map to entities Active is resolved. (I briefly had the idea to maybe use bundles for inbox and outbox, but view builder classes can't be split in core for now).

  • 🇧🇪Belgium swentel

    Regarding different templates: maybe it's better to have one template with a lot of if statements which is able to render urls, content, video images etc and then add suggestions based on $activity->getType(). cf Reader::buildMicrosubItem for inspiration.

  • 🇪🇸Spain aleix

    Let's see if you mean this. just a few notes here:

    Instead of creating a dedicated viewBuilder for activity entity, I used the hook https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21... . This could help us as in having to maintain it. I used the new oop hook from 11 ( https://www.drupal.org/node/3442349 ) as doing this also allows me to clean copy the buildMicrosubItem method (instead of creating a new service). The microsubitem is attached as #microsubitem in the entity render array.

    Also note that Controller is moved to an extended of EntityViewController, to reuse some of its parts and easier create the entity render array.

    The template part is not implemented yet and it outs the same as it was done (markup=> "Activity $id") as i'm out of time and getting too tired of nap time developing :)
    With all this changes, at least one can create templates in theme side to show nice timelines.

Production build 0.71.5 2024