federation refinement
This commit is contained in:
33
crates/adapters/sqlite/migrations/0004_username.sql
Normal file
33
crates/adapters/sqlite/migrations/0004_username.sql
Normal 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;
|
||||
11
crates/adapters/sqlite/migrations/0005_activitypub_v2.sql
Normal file
11
crates/adapters/sqlite/migrations/0005_activitypub_v2.sql
Normal 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;
|
||||
Reference in New Issue
Block a user