GM folks.

Khatru devs: Heads up. I'm making some backwards-incompatible changes to Khatru's Blossom API, as previously agreed with nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gprfmhxue69uhhq7tjv9kkjepwve5kzar2v9nzucm0d5hszxmhwden5te0wfjkccte9emk2um5v4exucn5vvhxxmmd9us2xuyp.

The three things to watch for are:

1. All blob-related events that take a sha256 will also receive a new string field (`ext`) with the file extension:

https://github.com/fiatjaf/khatru/blob/v0.18.2/blossom/server.go#L17-L26

2. If khatru can't detect the blob contents, `ext` will be empty and `BlobDescriptor.Type` will be `application/octet-stream`, in accordance with the latest Blossom specs:

https://github.com/hzrd149/blossom/blob/master/buds/01.md#get-sha256---get-blob

3. `GET /{sha256}` and `HEAD /{sha256}` will both pretty much ignore the file extension and return the blob with the `Content-Type` from the `BlobDescriptor`.

E.g., if you upload a PDF and later request `{sha256}.jpg`, Khatru’s Blossom server will still serve the original PDF with `Content-Type: application/pdf`.

(This is the best compromise given the current Blossom API, as agreed with nostr:nprofile1qqszv6q4uryjzr06xfxxew34wwc5hmjfmfpqn229d72gfegsdn2q3fgpzfmhxue69uhkummnw3e82efwvdhk6tcpz4mhxue69uhhyetvv9ujuerpd46hxtnfduhszythwden5te0dehhxarj9emkjmn99urf278z.)

I'll ping you again when this is merged.

Any thoughts or concerns, please let me know.

nostr:nprofile1qqsw9n8heusyq0el9f99tveg7r0rhcu9tznatuekxt764m78ymqu36cpr3mhxue69uhhyetvv9ujucnfw33k76twwpshy6ewvdhk6tcpzdmhxue69uhhwmm59e6hg7r09ehkuef0qy2hwumn8ghj7un9d3shjtn4w3ux7tn0dejj7ne6u4e, nostr:nprofile1qqs2qzx779ted7af5rt04vzw3l2hpzfgtk0a2pw6t2plaz4d2734vngpzamhxue69uhhyetvv9ujumn0wd68ytnzv9hxgtcppemhxue69uhkummn9ekx7mp0qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7hycrvd, nostr:nprofile1qqst6jhruelzn9jdf9qhyfsac3fetjyld0fwwary9cmxzfchrhacragppemhxue69uhkummn9ekx7mp0qy2hwumn8ghj76n9d3k8jenfwd5zumrpdejz7yj9f6t

(Feel free to ping anyone else who may be interested.)

#devstr #khatru #blossom

Reply to this note

Please Login to reply.

Discussion

Please at /mirror while you are at it 🙏

^ add

It's already implemented (fiatjaf is fast:)). https://github.com/fiatjaf/khatru/blob/master/blossom/handlers.go#L396

Nice … been a minute since I checked.

With fiatjaf and utxo, blink for a second and they’ve already implemented everything. Honestly, folks started bothering fiatjaf about mirroring because of Primal, and 24 hours later it was already on Khatru. Meanwhile, I’m still trying to get GitHub Actions to build some binaries after a couple of months messing with it, lol. If I weren’t older than both of them, I’d say that when I grow up, I want to be like them :)

Haven still has a compatibility issue with mirroring on Primal mobile (gracefully fixed by nostr:nprofile1qqsqxcftp6awpmydxqp3c3qt5zrllx73v2tzmla6fdhqy8ky4lt3y9spzemhxue69uhhyetvv9ujumn0wd68ytnzv9hxgqgswaehxw309ahx7um5wghxcctwvsq3qamnwvaz7tmwdaehgu3wwa5kuegrd0eh4 on Khatru). Otherwise, it’s working well (tested with Nak and Primal Web). When fiatjaf cuts the next version (hopefully with the changes I mentioned above) ’ll do some more testing on the mirror endpoint and update Haven. But if you’re using the latest master of Khatru, everything should already be working.

thanks for the shotout, but you and fiatjaf held my hand through all of that

The commit has your name in it :). Talk is cheap 🤣

And thanks for the zap by the way :)

Hi, thank you for informing. 🫡

I'll update my blossom servers accordingly. Wouldn't it break uploading and downloading the .apk files?

No, I'll keep the current if statement there. For now it's "it works on my machine". I'm testing it as throughly as I can and then send a PR to fiatjaf (likely this weekend). I'll ping you all again once it's merged and he cuts the next release.

is there a public branch or pr to follow?

Soon, I'll ping you the PR as soon as I'm more confident about it.

One eternity later... It took me over a month to feel “confident” about it (or rather, I totally forgot about it and moved on to something else, as usual 😂). I'm making this public now because I had to build on top of it to fix the Primal mirroring issue on mobile.

I can't open a PR because I’m not sure where to send it; Fiatjaf has a v2 fork of Khatru somewhere, and I don’t know if or where he wants me to contribute this. But here you go:

https://github.com/aaccioly-open-source/khatru/tree/feat/khatru-blossom-updates

If you want to test it in a Khatru-based relay, just run this magic incantation:

go mod edit -replace=github.com/fiatjaf/khatru=github.com/aaccioly-open-source/khatru@5425e6f793a0f19dd0ff9dda4c86ac1e1d1aeb66

go get -u github.com/fiatjaf/khatru

The changes are very straightforward. Just add the new ext string parameter wherever the compiler complains about it:

https://github.com/aaccioly-open-source/haven/commit/6c1b9e06a3c187e5f7b32272c56a5fedbac046e8