federation refinement

This commit is contained in:
2026-05-09 13:53:45 +02:00
parent df71748897
commit 470b29c9e1
56 changed files with 1513 additions and 544 deletions

View File

@@ -0,0 +1,33 @@
-- Recreate users table with username column
CREATE TABLE users_new (
id TEXT PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
username TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
created_at TEXT NOT NULL
);
-- Derive username from email local part, sanitising common invalid chars.
-- REPLACE chains handle the most common email chars. The NOT NULL UNIQUE
-- constraint will surface any remaining collision (rare for personal instances).
INSERT INTO users_new (id, email, username, password_hash, created_at)
SELECT
id,
email,
CASE
WHEN LENGTH(REPLACE(REPLACE(REPLACE(REPLACE(
LOWER(SUBSTR(email, 1, INSTR(email, '@') - 1)),
'.', '_'), '+', '_'), '-', '-'), ' ', '_')) < 2
THEN REPLACE(REPLACE(REPLACE(REPLACE(
LOWER(SUBSTR(email, 1, INSTR(email, '@') - 1)),
'.', '_'), '+', '_'), '-', '-'), ' ', '_') || '_x'
ELSE REPLACE(REPLACE(REPLACE(REPLACE(
LOWER(SUBSTR(email, 1, INSTR(email, '@') - 1)),
'.', '_'), '+', '_'), '-', '-'), ' ', '_')
END,
password_hash,
created_at
FROM users;
DROP TABLE users;
ALTER TABLE users_new RENAME TO users;

View File

@@ -0,0 +1,11 @@
-- Store the original Follow activity URL so Undo/Reject can reference it correctly
ALTER TABLE ap_following ADD COLUMN follow_activity_id TEXT;
-- Track whether our outbound follow was accepted by the remote server
ALTER TABLE ap_following ADD COLUMN status TEXT NOT NULL DEFAULT 'pending';
-- Store the AP object URL on reviews so DeleteActivity can target by ID
ALTER TABLE reviews ADD COLUMN ap_id TEXT;
-- Partial unique index: ap_id is only set on remote reviews; local reviews have NULL
CREATE UNIQUE INDEX IF NOT EXISTS idx_reviews_ap_id ON reviews (ap_id) WHERE ap_id IS NOT NULL;