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

Activitypub/Sprint 1 #3193

Merged
merged 40 commits into from Feb 22, 2024
Merged

Activitypub/Sprint 1 #3193

merged 40 commits into from Feb 22, 2024

Conversation

mediaformat
Copy link
Contributor

@mediaformat mediaformat commented Feb 5, 2024

ActivityPub Sprint 1

#3186

  • Setup / Planning
  • Add new json_activity templates and endpoints (profiles, posts)
  • Add ActivityPub actor URI to webfinger
  • Add ActivityPub link-rel discovery to html templates

Additional

Here's what I fixed or added:

This PR is focused on the Actor/user Profile and default enabled Post types (note, article, image).
The PR is pointing to idno:dev branch but perhaps a feature branch might be more appropriate.

  • Some methods to the User class
    • getActorID
    • getIconObject
    • getPublicKey
    • getPublicKeyPem
    • getPrivateKey
    • generateKeyPair
    • ...
  • Some methods to the Entity class
    • ...
  • A separate /actor/ route specifically for ActivityPub profile
  • A new activitypub default/shell template for <link rel="alternate" type="application/activity+json" ...>

Here's why I did it:

Separate Actor routes

Content-Negotiation

By adding separate actor routes, we seek to avoid Content-Negotiation (accessing the same route with different Accept headers) which can cause different servers, caching solutions to cache and serve the wrong version (html/json).

Mastodon's Signature verification issue

While it would be possible to use existing routes with the ?_t=activitypub template query, mastodon has a known issue with verifying HTTP signatures. Though the issue was recently solved in mastodon, it requires a second request for backwards compatibility.

Checklist: ([x] to check/tick the boxes)

  • This pull request addresses a single issue
  • If this code includes interface changes, I've included screenshots in this Pull Request thread
  • I've adhered to Known's style guide (these codesniffer rules might help!)
  • My git branch is named in a descriptive way - i.e., yourname-summary-of-issue
  • I've tested my code in-browser
  • My code contains descriptive comments
  • I've added tests where applicable, and...
  • I can run the unit tests successfully.

@mediaformat mediaformat marked this pull request as ready for review February 12, 2024 17:47
@mediaformat
Copy link
Contributor Author

Additional Notes:
Because ActivityPub is to be part of the core, I've put most methods in the Entity class, while some may be more related to formatting, but these include Formatted in the method name for clarity.

I'm making use of existing parseHashTag() and parseURL() methods for formatting, and though they do work for now, they each have issues, I'll address in the coming days:

@mediaformat
Copy link
Contributor Author

I've adhered to the styleguide, but running codesniffer is on my todo list.

@benwerd
Copy link
Member

benwerd commented Feb 12, 2024

🎉🎉 🎉 🎉

Reviewing now!

Copy link
Member

@benwerd benwerd left a comment

Choose a reason for hiding this comment

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

LG with some suggestions to clearly scope AP methods in their names. THANK YOU!!

Idno/Common/Entity.php Show resolved Hide resolved
Idno/Common/Entity.php Show resolved Hide resolved
Idno/Entities/User.php Outdated Show resolved Hide resolved
Idno/Entities/User.php Outdated Show resolved Hide resolved
@mediaformat
Copy link
Contributor Author

@benwerd Good to go!

@mediaformat
Copy link
Contributor Author

Actually, I've just found a bunch of errors and warnings running the code sniffer.

A TOTAL OF 148 ERRORS WERE FIXED IN 35 FILES
PHPCBF FAILED TO FIX 18 FILES

Will fix these...

@mediaformat
Copy link
Contributor Author

mediaformat commented Feb 13, 2024

I can't seem to get phpunit working even after having done export KNOWN_DOMAIN='known.local'.

Otherwise good to go!

@mediaformat
Copy link
Contributor Author

Ready to go

Copy link
Member

@benwerd benwerd left a comment

Choose a reason for hiding this comment

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

LG!!!!! 👍

@benwerd benwerd merged commit b33621d into idno:dev Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants