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!
David :ubuntu: :android: :php: says:
@blog @example
Love this project!
Was skimming the project README and that last requirements line got me 😄
Raphael Luckom says:
@blog Thanks! Much respect for just getting this out there. Love the comments! 😂
Ricard Torres said on ricard.social:
@Edent Just wanted to say, this is an awesome idea and so simple!
Here I am hosting a Mastodon instance 🤪
More comments on Mastodon.