What is Nostr?
Terence Eden’s Blog /
npub1lyw…ruez
2024-03-03 12:34:16

Terence Eden’s Blog on Nostr: Updates to ActivityPub in a single PHP file ...

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!

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

#ActivityPub #php
Author Public Key
npub1lywey3rjuskr7kstpvwj3xafa56qrkfc6r7f665rxvw4sv2jw6ps5vruez