feat(hub): let users upload their own avatar
POST/DELETE /v1/account/avatar (session, exact Origin, CSRF) and public GET /v1/avatars/<id>. Uploads are sniffed, size and dimension limited, fully decoded, re-encoded to a 256x256 PNG without metadata and stored in SQLite, one per account. avatar_url in the session points to it, with the provider avatar as fallback. Claude-Session: https://claude.ai/code/session_01GDjxLvBcnJqniFQGUGb1V4
This commit is contained in:
parent
fea876654b
commit
a2b0f26645
15 changed files with 1332 additions and 13 deletions
12
hub/migrations/0005_avatars.sql
Normal file
12
hub/migrations/0005_avatars.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- One own avatar per account, stored as a re-encoded PNG (no source metadata). The row is
|
||||
-- replaced on upload and removed on "remove photo" or when the account is deleted. `id` is the
|
||||
-- hex SHA-256 of the stored bytes; it names the immutable public URL /v1/avatars/<id>.
|
||||
-- accounts.avatar_url keeps the provider (GitHub) avatar as the fallback.
|
||||
CREATE TABLE avatars (
|
||||
user_id TEXT PRIMARY KEY REFERENCES accounts(user_id) ON DELETE CASCADE,
|
||||
id TEXT NOT NULL,
|
||||
content_type TEXT NOT NULL,
|
||||
bytes BLOB NOT NULL,
|
||||
created_at INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX avatars_by_id ON avatars(id);
|
||||
Loading…
Add table
Add a link
Reference in a new issue