cobysher.dev

Webmentions Rock! part 1

#webmentions #indieweb

If you’ve been keeping up with my posts on the fediverse about this topic, thanks! If not, here’s what I’ve been up to in my at home coding the past few month and a half or so.

Challenge Accepted

Being a bootcamp grad (and recently minted senior software engineer) with only a few years of experience, the impostor syndrome is very real. So to prove only to myself that I could, I challenged myself to implement something from a spec. That challenge came about sort of retroactively after reading about webmentions and the indie web, which aligns with how I want to build my presence on the web.

The spec was not very long and seemed simple enough after reading it a few times. Oh wow. How I was wrong about that. I will get into that more later.

Host With the Most

Part of this new obsession of implementing a webmentions server from scratch was also a desire to begin self hosting things when possible. Aided by a neglected mac mini that is sitting in the house. I decided to put Asahi Linux on it (because I was having issues with macOS as a server environment) and started slapping a bunch of podman containers up with various services. This has been a lot of fun and a lot of learning about DNS, web servers, containers, and more. I am looking forward to continuing down this infinite rabbit hole by setting up log drains and exploring additional hardware.

Enter the Orange Tunnel

In wanting to self host my webmentions server too. I containerized it, mostly for fun, and put it behind a Cloudflare tunnel. Is this wise? Probably not. But I have added a number of WAF rules that make me feel more comfortable about this setup. Part of why I am comfortable with this is I don’t expect to get much traffic. If it ends up becoming an issue, I will likely move to some cloud provider. Until then, we’ll see how it goes!

Building the Server

I followed a number of blog posts and read a fair amount to get ready to start building the server. I thought I had all I needed from the spec, which was mostly true. I also utilized the Webmentions Rocks to help test my implementation. This was super helpful in catching some edge cases. I got every test to pass, however in passing test 23, I broke many others, so I decided to let that edge case be damned. I am using the URL() constructor to paste together the hostname and the query parameters, and that doesn’t play well well with the edge case introduced in test 23. One day maybe I will fix it…

In building the server I came upon some wording that didn’t really faze me at first, but then I realized it required me to build a queue which meant integrating redis! This was really fun for me. I don’t know why but I really nerd out when I am able to use tools like this, so I jumped at the opportunity to add a bull queue to the project to handle validating incoming webmentions. I don’t have a fancy HTML page showing the status of the webmention, but I wanted to leave some nice-to-have features to add in the future if I wanted to keep working on this.

What’s In a Spec?

Since I had never had to implement anything straight from a spec before, I was unaware of the potential pitfalls. In this case, the spec doesn’t tell you what to do after the webmention is POSTed to your server. It says you can display the HTML. That’s all. I can be a very literal person sometimes, so it took me about a glass of fresh squeezed brain juice to realize that I did in fact need a database to store the webmention HTML too. This is when I started to understand that specs are probably vague on purpose. If you give a mouse a cookie and all that.

What this meant to me that I couldn’t rely only on what was in the spec. I had to think about how to support the spec with things that didn’t live inside of it. This was not obvious at first and I wonder if it is a feature or a bug of these things. I could see it either way.

Obsidian Blog Engine

I am writing this as part 1 because I still want to clean up the code and make it public. Related to that work, I want to rename my diy-obsidian-sync project to something more apt to it’s purpose which is a blogging engine (it’s how I’m writing and publishing this very post!). With that rebrand I want to include more indieweb features, and the blog engine had some updates to facilitate the publishing of webmentions as well! Hopefully I will unveil all of that in part 2, so stay tuned.

Sound Off!

I’m not going to lie: I want to see if this thing really works! So if you have webmentions enabled on your blog, give this post a mention and let me know what you think!

Created on:
Last updated:

Webmention Replies

webmentions.pleasant.rest | 502: Bad gateway

Bad gateway Error code 502

Visit cloudflare.com for more information.
2024-04-25 13:03:48 UTC
You

Browser

Working
Chicago

Cloudflare

Working
webmentions.pleasant.rest

Host

Error

What happened?

The web server reported a bad gateway error.

What can I do?

Please try again in a few minutes.

<< Go Back