Changeset cca2e89 in Klonkt for src/middleware


Ignore:
Timestamp:
06/28/2026 01:15:39 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
9910ba1
Parents:
931b4cb
Message:

feat(identity): one image — the site photo is the only avatar input

Removed the separate account-avatar upload. A user's avatar everywhere (nav, account, profile
header, fediverse) is now their SITE photo, set in one place (site settings). The account page
shows it read-only with a link.

  • middleware/render.js — nav avatar = site photo always; drop the account-avatar cross-fallback
  • views/pages/account.ejs — remove the avatar upload; read-only site photo + hint to site settings
  • services/i18n.js — acct.photo_site_hint (nl/en/de)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/render.js

    r931b4cb rcca2e89  
    7171  // avatar change or role switch) heals itself without a new login.
    7272  if (_u && _u.id) {
    73     const _fresh = db.prepare('SELECT avatar_url, role, lang FROM users WHERE id = ?').get(_u.id);
    74     if (_fresh) _u = { ..._u, avatar_url: _fresh.avatar_url, role: _fresh.role, lang: _fresh.lang };
    75     // One identity: no own account avatar → fall back to the user's site photo,
    76     // so the same picture shows everywhere (nav, account, comments).
    77     if (_u && !_u.avatar_url) {
    78       const _sp = db.prepare("SELECT profile_photo FROM sites WHERE owner_id = ? AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1").get(_u.id);
    79       if (_sp && _sp.profile_photo) _u = { ..._u, avatar_url: _sp.profile_photo };
    80     }
     73    const _fresh = db.prepare('SELECT role, lang FROM users WHERE id = ?').get(_u.id);
     74    if (_fresh) _u = { ..._u, role: _fresh.role, lang: _fresh.lang };
     75    // ONE image: a user's avatar everywhere (nav, account, comments) is simply their SITE
     76    // photo — there is no separate account avatar. Falls back to the initial-letter
     77    // placeholder when the site has no photo yet.
     78    const _sp = db.prepare("SELECT profile_photo FROM sites WHERE owner_id = ? AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1").get(_u.id);
     79    _u = { ..._u, avatar_url: (_sp && _sp.profile_photo) || null };
    8180  }
    8281  const userOwnsSite = !!(_u && _u.role !== 'god' &&
    8382    db.prepare('SELECT 1 FROM sites WHERE owner_id = ? LIMIT 1').get(_u.id));
    8483
    85   // The avatar of the SITE OWNER (not the viewer!) — for the Klonkt site header,
    86   // so the artist can use their own account photo as the site photo.
    8784  const _site = data.site || res.locals.site || null;
    88   const siteOwnerAvatar = (_site && _site.owner_id)
    89     ? (db.prepare('SELECT avatar_url FROM users WHERE id = ?').get(_site.owner_id)?.avatar_url || null)
    90     : null;
     85  // The site header uses the SITE photo (site.profile_photo) — the one and only image,
     86  // set in site settings. (No separate account-avatar fallback anymore.)
     87  const siteOwnerAvatar = null;
    9188
    9289  // Viewer mode: may view everything, change nothing. Views use canMutate
Note: See TracChangeset for help on using the changeset viewer.