Changeset cca2e89 in Klonkt for src/middleware
- Timestamp:
- 06/28/2026 01:15:39 PM (2 months ago)
- Branches:
- main
- Children:
- 9910ba1
- Parents:
- 931b4cb
- File:
-
- 1 edited
-
src/middleware/render.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/render.js
r931b4cb rcca2e89 71 71 // avatar change or role switch) heals itself without a new login. 72 72 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 }; 81 80 } 82 81 const userOwnsSite = !!(_u && _u.role !== 'god' && 83 82 db.prepare('SELECT 1 FROM sites WHERE owner_id = ? LIMIT 1').get(_u.id)); 84 83 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.87 84 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; 91 88 92 89 // Viewer mode: may view everything, change nothing. Views use canMutate
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)