Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/event objects #629

Merged
merged 39 commits into from
Jan 18, 2024
Merged

Add/event objects #629

merged 39 commits into from
Jan 18, 2024

Conversation

Menrath
Copy link
Contributor

@Menrath Menrath commented Jan 2, 2024

I started this pull request as a minimal one, with only adding an Event class but I ended up also shaping the way the Json-LD context is build a bit. It is now tied to the ActivityPub objects.

Reason: Don't store and send context which is never referenced.

- change the propertyname  which stores the json-ld context from context to _context, because context is already reserved in the ActivityStreams vocabulary.
- cleanup currently unused code
@pfefferle
Copy link
Member

The context handling is a bit complicated and confusing.

Can we maybe find a way to have only the context attribute and work with set_context to replace it and add_context to extend it instead of using _context?

@Menrath
Copy link
Contributor Author

Menrath commented Jan 3, 2024

Or maybe don't use a property for the JsonLD context at all, just use a getter function called "get_json_ld_context".
Then there should be no confusion between the jsonld-context ('@context') and the term context ('context') from the ActivityStreams.

@pfefferle
Copy link
Member

pfefferle commented Jan 3, 2024

Ah, that is the difference! Makes sense!

Then I would really vote for having it only as const and think about how to handle it in to_array and to_json methods!

@Menrath Menrath marked this pull request as draft January 5, 2024 15:06
@Menrath
Copy link
Contributor Author

Menrath commented Jan 5, 2024

Converted it to draft to signalize that there is no hurry and we might discover some little enhancements in the next few weeks anyway!

Menrath and others added 9 commits January 15, 2024 18:03
We already set the correct user with `$transformer->change_wp_user_id( $user_id );` so the Actor will be generated properly. We can change the behaviour, but we should not use both.
this should stay as is, because it pre-fills the Activity with data (for example cc and to) and it will no longer be done with your change.

It is on purpose that it first sets the object and then replaces it with the URI.

See: https://github.com/Automattic/wordpress-activitypub/blob/master/includes/activity/class-activity.php#L195
@pfefferle
Copy link
Member

@Menrath I added some changes, can you verify them and I had one more inline question!

Copy link
Contributor Author

@Menrath Menrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e8db7e9
Great that you saw that, it was probably a leftover before the function change_wp_user_id was available: Mobilizon currently requires the actor attribute also on the event object itself, although it is against the ActivityPub standard.

includes/rest/class-outbox.php Outdated Show resolved Hide resolved
templates/author-json.php Show resolved Hide resolved
includes/activity/class-base-object.php Show resolved Hide resolved
includes/activity/class-postal-address.php Outdated Show resolved Hide resolved
includes/activity/class-base-object.php Outdated Show resolved Hide resolved
includes/rest/class-collection.php Outdated Show resolved Hide resolved
includes/rest/class-collection.php Outdated Show resolved Hide resolved
includes/activity/class-base-object.php Show resolved Hide resolved
@Menrath
Copy link
Contributor Author

Menrath commented Jan 17, 2024

@pfefferle Thanks for your review again! Looks good to me!

A slightly off topic last question that comes to my mind: what about calling the to_object function to_activitypub_object? For improving searchability of the where it's used.

Copy link
Contributor Author

@Menrath Menrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

includes/activity/class-base-object.php Show resolved Hide resolved
Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops 😳

thanks!

I hope this is fine, to have the complete plugin under the MIT @Menrath ?!?
Copy link
Contributor Author

@Menrath Menrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed licensing. I have no experience to be honest. I am fine with it. Our extensions plugin will be AGPLv3 only though :)

@pfefferle pfefferle merged commit 174262d into Automattic:master Jan 18, 2024
10 checks passed
@carstingaxion
Copy link

carstingaxion commented Feb 13, 2024

What an enormous PR! Congrats and Thank you very much for your contribution @Menrath and @pfefferle

… and all this even without an issue ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants