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
12 lines
607 B
SQL
12 lines
607 B
SQL
-- 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);
|