58 Commits
Author SHA1 Message Date
Johanna LarssonandTangled 695a7d981c Allow blobs to be owned by multiple accounts
The current tranquil database design only allows each blob to be owned by one account. This means that if a second account also has that blob, tranquil skips associated the blob with the account. That works fine a lot of the time, since blobs are looked up by cid and the blob exists. However, it can lead to loss of data under certain scenarios.

One example is where I upload a blob, the blob already exists in my instance so insertion is skipped (postgres requires cid to be unique in blobs, fjall only allows one owner per blob cid), I then decide to migrate off tranquil, the blob does not come with me since it is not mine.

Another example is where an account is deleted. If a blob was uploaded for account a, then account b uploads the same blob tranquil skips storing it since it exists. Then I delete account a, now account b's blob is missing.

I accidentally stumbled upon this when I migrated my account to my own tranuil instance and list blobs now lists 2 fewer blobs than before, two images that had been uploaded by accounts already on the PDS.

ps I found record_blobs a bit confusing, at first it looked like a blob ownership table, but then it turns out to just be used for migrations!

This PR makes the blob primary key be cid+user for postgres, and updates the queries to account for there being multiple "blobs" with the same cid. For queries that just care about the blob existing, it doesn't matter "whose" blob it is, so limit 1.

Most of the work is on the metastore side. Adds ref_count to track how many are referencing the blob since we can't just check for other rows. Instead of storing blobs directly, we now store a per account cid, and the blob reference itself is shared and keyed by cid only. This means some of these operations now require updating two places, so they're done in `batch`es.

With the new layout get_blob_value becomes simpler, all blob data is a single "table" or whatever it's called, so we just grab it using cid instead of looking it up for the user.

Migrates blobs rather than maintaining two different versions of the tables, although it seems like that could be supported.

I removed a test that asserted the old behavior, and added a reasonable (?) set of new tests that assert the new behavior, including a parity test.
2026-09-12 15:34:46 +00:00
LewisandTangled d00d72895a store: record-by-cid reverse index
Lewis: May this revision serve well! <lu5a@proton.me>
2026-07-25 08:27:40 +03:00
LewisandTangled 0c7cccb14c invite: require owning account for generated codes
Lewis: May this revision serve well! <lu5a@proton.me>
2026-07-25 08:27:39 +03:00
Lewis ab4eba6dc4 delegation: preset scopes grant identity & account
Lewis: May this revision serve well! <lu5a@proton.me>
2026-06-27 23:11:24 +03:00
LewisandTangled e9dc57d6f4 fix(firehose): lost events if seq commits out of order
Lewis: May this revision serve well! <lu5a@proton.me>
2026-05-30 21:10:38 +03:00
LewisandTangled 4d2c7d4723 feat(auth): verification-gate override, inbound-migration bypass, store deleter improvement
Lewis: May this revision serve well! <lu5a@proton.me>
2026-05-23 23:02:43 +03:00
Lewis 05246aec58 feat(tranquil-store): gc and hardening
Lewis: May this revision serve well! <lu5a@proton.me>
2026-04-10 13:57:47 +03:00
LewisandTangled e6c8a44a42 feat(signal): add postgres-backed signal protocol store 2026-03-22 07:14:19 +00:00
LewisandTangled ebf5af4922 fix(backups): remove useless backups concept 2026-03-18 12:17:33 +00:00
LewisandTangled 7926c798c6 feat: cross-pds delegation 2026-03-17 19:22:34 +00:00
lewisandTangled cd7400bc8b fix: improved discord & signal comms 2026-02-05 16:13:45 +00:00
lewisandTangled b104dc938a fix: telegram comms ux improvements 2026-02-04 19:08:44 +00:00
lewisandTangled 442ca1434f fix: better dashboard UX 2026-02-02 19:29:03 +00:00
lewisandTangled 2b31a288a9 fix: no preference dedup needed 2026-01-27 15:12:15 +00:00
lewisandTangled 12a189cb2b feat: oauth prompt=create, other frontend fixes 2026-01-19 17:44:24 +00:00
lewis b3ec7feb96 sso signup & login 2026-01-18 01:15:13 +02:00
lewis 1a916aa30e migrations for repo_rev tracking and backlinks table 2026-01-14 22:22:07 +02:00
lewis 9a516a012d Remove old user blocks 2026-01-06 19:49:42 +02:00
lewis 0f32cc3faa Performance improvements 2026-01-03 00:58:28 +02:00
lewis df2135b5e1 Backups, adversarial migrations 2026-01-02 00:24:32 +02:00
lewis 4d6e21b00d pds-hosted did migrates away 2025-12-30 21:16:49 +02:00
lewis 7be60ea2d1 Fixed migration problem 2025-12-30 23:45:44 +02:00
lewis 3b52a42156 Invite codes conf. vs ref 2025-12-29 20:00:58 +02:00
lewis 8cfc13fccc App password conf. vs ref 2025-12-29 19:36:01 +02:00
lewis c302d2aea1 Account lifecycle conf. vs ref 2025-12-29 21:51:09 +02:00
lewis 8cb82abc82 Store rev properly like a good boy 2025-12-28 02:24:09 +02:00
lewis ff59c29147 Delegated accounts 2025-12-26 20:15:45 +02:00
lewis 3f727b1c9d App password scopes 2025-12-25 21:17:09 +02:00
lewis d8451f3219 'Clever' stateless token verification. We could revert later if it sucks. 2025-12-24 23:57:49 +02:00
lewis 11fc081971 Generic cosmetic per-server config 2025-12-23 20:35:17 +02:00
lewis 9037d6bfa3 Locales in frontend, why not 2025-12-22 18:02:32 +02:00
lewis d80247ba43 Security improvements 2025-12-22 21:09:09 +02:00
lewis fa6c4cc177 Passkey-only accounts 2025-12-21 23:16:39 +02:00
lewis adfa9a3812 Better handles 2025-12-21 17:53:25 +02:00
lewis 45b6b58ad6 Security key & totp support 2025-12-20 21:41:29 +02:00
lewis 3177dc42f5 did:web support, including our own internal kind 2025-12-20 17:36:33 +02:00
lewis faea661917 OAuth scopes full impl. 2025-12-20 13:05:43 +02:00
lewis d695135a4d Rename notifications to comms, add handle changing to own domain ability 2025-12-18 20:35:15 +02:00
lewis dea6c09aa0 Add admin functionality 2025-12-16 18:28:20 +02:00
lewis e2bfcdb74f More work on the pds notifs 2025-12-16 18:00:44 +02:00
lewis c6f9062979 Creating & posting records works. Also messed up newlines but will fix later. 2025-12-14 23:55:04 +02:00
lewis 43c18beb51 Performance enhancements, overengineering 2025-12-13 15:10:53 +02:00
lewis 7b6807c316 First UI idea done 2025-12-12 23:52:52 +02:00
lewis b66e4fe291 Remaining endpoints for MVP 2025-12-12 19:20:39 +02:00
lewis 2ededf32a6 Half-ass attempt at the local-first appview endpoints like ref impl 2025-12-12 00:28:57 +02:00
lewis ea7837fcec First version of pds migration 2025-12-11 17:10:19 +02:00
lewis 2eb67eb688 Actor preferences 2025-12-11 23:23:55 +02:00
lewis 17a7f1dc2b Initial oauth impl 2025-12-11 20:05:59 +02:00
Lewis c09f0e9982 Initial firehose connections 2025-12-10 19:24:10 +02:00
lewis 8cfea3b480 Gearing up for migration endpoints 2025-12-09 23:35:06 +02:00