Skip to content

Piero Bosio Social Web Site Personale Logo Fediverso

Social Forum federato con il resto del mondo. Non contano le istanze, contano le persone

Updates to ActivityPub in a single PHP file

General Discussion
3 3 7
  • Updates to ActivityPub in a single PHP file

    https://shkspr.mobi/blog/2024/03/updates-to-activitypub-in-a-single-php-file/

    A few weeks ago, I built an ActivityPub Server in a Single PHP File. It's a proof of concept showing how easy it is to turn a website into a full-featured Fediverse participant.

    After a bunch of feedback and testing, I've added a some features to make it slightly more useful.

    • A single PHP file - 45KB of no-library goodness. Just add your details, upload, and done.
    • No databases. Everything stored as JSON files on disk.
    • Be followed. External users can discover and follow you.
    • Send messages. You can send messages to all your followers.
    • 🆕 Follow users. You can follow other Fediverse actors.
    • 🆕 Read messages. You can read the messages sent to your Inbox. If media is attached, those will be displayed.
    • 🆕 Verify signatures. ActivityPub messages can by cryptographically signed. This now verifies those signatures.

    You can grab the code here - pull requests welcome. If you want to see what it looks like in action, visit https://example.viii.fi/ or follow @example@example.viii.fi.

    Again, to re-emphasise what it says in the README - this is not suitable for production use. This is primarily a way to explain all the different functions of an ActivityPub server. It is adequately commented and I hope a moderately competent programmer could follow what's going on. It is almost certainly insecure and is considered harmful to aquatic life.

    I would be delighted if you took the code and did something interesting with it. Perhaps create a single-file server in your favourite language?

    ToDo

    A few random things which I might add - or which you might consider making and sending a Pull Request:

    • Better UI. It is deliberately bare-bones, see the /read interface. But perhaps there's a simpler way to make it look nice?
    • No threading in the UI - and no ability to reply to messages.
    • Support for reading hashtagged posts on the site.
    • Reply highlighting - at the moment you can't see if a message was sent to you.
    • Some Fediverse posts contain polls, content warnings, and other extended features. That could be fun to support - both for reading and writing.
    • Support for reading custom emoji.
    • Deletes, Updates, and Undos are received - but it currently doesn't remove the previously saved file.
    • There's no way to unfollow a user - except for manually deleting data from the file-system.
    • Only supports one image upload. Could support more? Or even other media?
    • I don't think CC works properly.
    • Message visibility could be useful.
    • Boring stuff like better error handling.

    If you have opinions, please let me know!

  • Updates to ActivityPub in a single PHP file

    https://shkspr.mobi/blog/2024/03/updates-to-activitypub-in-a-single-php-file/

    A few weeks ago, I built an ActivityPub Server in a Single PHP File. It's a proof of concept showing how easy it is to turn a website into a full-featured Fediverse participant.

    After a bunch of feedback and testing, I've added a some features to make it slightly more useful.

    • A single PHP file - 45KB of no-library goodness. Just add your details, upload, and done.
    • No databases. Everything stored as JSON files on disk.
    • Be followed. External users can discover and follow you.
    • Send messages. You can send messages to all your followers.
    • 🆕 Follow users. You can follow other Fediverse actors.
    • 🆕 Read messages. You can read the messages sent to your Inbox. If media is attached, those will be displayed.
    • 🆕 Verify signatures. ActivityPub messages can by cryptographically signed. This now verifies those signatures.

    You can grab the code here - pull requests welcome. If you want to see what it looks like in action, visit https://example.viii.fi/ or follow @example@example.viii.fi.

    Again, to re-emphasise what it says in the README - this is not suitable for production use. This is primarily a way to explain all the different functions of an ActivityPub server. It is adequately commented and I hope a moderately competent programmer could follow what's going on. It is almost certainly insecure and is considered harmful to aquatic life.

    I would be delighted if you took the code and did something interesting with it. Perhaps create a single-file server in your favourite language?

    ToDo

    A few random things which I might add - or which you might consider making and sending a Pull Request:

    • Better UI. It is deliberately bare-bones, see the /read interface. But perhaps there's a simpler way to make it look nice?
    • No threading in the UI - and no ability to reply to messages.
    • Support for reading hashtagged posts on the site.
    • Reply highlighting - at the moment you can't see if a message was sent to you.
    • Some Fediverse posts contain polls, content warnings, and other extended features. That could be fun to support - both for reading and writing.
    • Support for reading custom emoji.
    • Deletes, Updates, and Undos are received - but it currently doesn't remove the previously saved file.
    • There's no way to unfollow a user - except for manually deleting data from the file-system.
    • Only supports one image upload. Could support more? Or even other media?
    • I don't think CC works properly.
    • Message visibility could be useful.
    • Boring stuff like better error handling.

    If you have opinions, please let me know!

    @blog @example

    Love this project!

    Was skimming the project README and that last requirements line got me 😄

  • @blog Thanks! Much respect for just getting this out there. Love the comments! 😂


Gli ultimi otto messaggi ricevuti dalla Federazione
Post suggeriti
  • 0 Votes
    6 Posts
    35 Views
    @hongminhee@hollo.social ah yes, implements would be a good thing to support. It would allow you to cache the value temporarily (maybe a quick recheck every 7 days or so) so as to avoid needing a double knock at all. Caching based on first knock success also works. I wonder if sending HTTP 426 is doable too... 🤔 https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/426
  • 0 Votes
    1 Posts
    5 Views
    mein hirn macht gleich bumm #activitypub learning
  • 0 Votes
    1 Posts
    11 Views
    The big feature in release v3.2.2 of Ktistec is pinned posts with support for the Mastodon Featured Posts collection. Federation works both ways—pin a post on Ktistec and it will show up as a pinned post on Mastodon and vice versa. When you refresh an actor profile, Ktistec also fetches and updates the actor's pinned posts. This is another small step in the direction of supporting all features that Mastodon-compatible client applications expect to access via the API. It's also useful in its own right. The other major feature, which I posted a short video demonstrating here, is X-Ray Mode. X-Ray Mode is a developer and power-user tool for inspecting ActivityPub JSON-LD representations of actors, objects, and other content. Pressing Ctrl+Shift+X on any page displays the data behind the page—like an x-ray. You can:Cached Version: View the local JSON-LD representation stored in the Ktistec databaseRemote Version: Fetch and view the original JSON-LD representation from the source serverNavigation: Click on any ActivityPub IRI to navigate to that objectHistory: Use Alt+Left and Alt+Right to navigate through your viewing historyThis feature is useful for debugging federation issues, understanding ActivityPub structures, and verifying how content is stored and represented.Here's the full changelog for the release:AddedSupport for pinned posts and the Mastodon "featured posts" collection.X-Ray Mode for viewing and navigating JSON-LD resource (actor, object, etc.) representations.Back links on thread pages for easier navigation. (fixes #1)License page for LibreJS compliance. (fixes #127)Highlighting of recently fetched hashtagged posts.ChangedImproved presentation of audio and video media.Refactored theming/styling implementation.The next release will focus on smaller features and bug fixes.Enjoy!#ktistec #crystallang #activitypub #fediverse
  • 0 Votes
    1 Posts
    18 Views
    finally 🥳#loops #activityPub