mirror of
https://github.com/PR0M3TH3AN/Artstr-Studio.git
synced 2026-10-27 08:40:39 +00:00
A salvage tool in Settings. Sweeps every Artstr design still readable, saves the signed events to a JSON bundle, and re-publishes them to the current relays so designs survive a relay going dark. Reads as widely as possible: the user's relays plus the old defaults, deliberately including relays marked dead, since one unreachable from this network may answer from another and a dying relay is exactly the one holding events worth rescuing. Signed in, it also sweeps the signer's own events by author, which is the only way to reach private and premium designs - those carry randomised d-tags and no public tag. The pubkey is requested from the signer directly rather than read from state.community.myPubkey: a connected extension does not populate that, and during testing the tool reported "0 of mine" while the key in fact had 233 authored designs, 18 of them encrypted. Every private design would have been skipped. Two rules the tool will not bend, because getting them wrong is worse than not running: - Retractions are honoured. A blanket `#k: 30078` deletion filter came back with 670 unrelated kind-5 events from across the network, all of which would have been rebroadcast; the lookup is now scoped to the authors actually collected and further filtered to deletions that target this archive. Those go out first, so a relay learns a design was withdrawn before anything can put an older copy back. - Only the newest revision of each addressable design is sent. Publishing uses one socket per relay - publishToRelays opens a fresh connection per event, which for 230 events across 6 relays would be ~1400 connections and immediate rate-limiting. Each event is awaited individually with a bounded in-flight window and a single retry on rate-limit, so every one is accounted as accepted / rejected / unanswered. That last part took three attempts. Fire-and-forget with an idle-timeout completion check kept closing the socket on the unsent tail once designs ran to megabytes and acknowledgements lagged the sends - runs reported 26, 46 and 202 acceptances out of 230 while claiming success. Verified against a local mock relay that simulates rate-limiting: 230/230 accepted, 0 unanswered, relay-side counts matching exactly, and end-to-end 238 found / 230 sent / 230 accepted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>