diff --git a/accounts.js b/accounts.js index de72d0e..06e429c 100644 --- a/accounts.js +++ b/accounts.js @@ -499,7 +499,7 @@ module.exports = { init, signup, login, ensure, onChange, byEmail, byAddress, by setUsername, reservedUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, count, setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t), setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j), - setProfile: (e, a, bio, socials) => impl().setProfile(String(e || '').toLowerCase(), a, bio, socials), + setProfile: async (e, a, bio, socials) => { const r = await impl().setProfile(String(e || '').toLowerCase(), a, bio, socials); if (!(r && r.error)) changed(String(e || '').toLowerCase()); return r; }, // profile edits reach LinkSpin too touchSeen: e => impl().touchSeen(String(e || '').toLowerCase()), adminSetAddress: (e, a) => impl().adminSetAddress(String(e || '').toLowerCase(), a ? normAddr(a) : null), positionByAddress: a => impl().positionByAddress(normAddr(a)), diff --git a/lssync.js b/lssync.js index 72ee290..affcb9a 100644 --- a/lssync.js +++ b/lssync.js @@ -22,9 +22,20 @@ function init(deps) { R = deps; load(); } async function rowFor(acct, byRef) { const ref = String(acct.sponsorRef || '').toLowerCase(); let sponsorEmail = null; if (ref) { const sp = byRef ? byRef.get(ref) : (await R.accounts.byUsername(ref) || await R.accounts.byCode(ref)); if (sp && sp.email !== acct.email) sponsorEmail = sp.email; } - return { email: acct.email, username: acct.username || null, wallet: acct.address || null, sponsorEmail, joinedAt: Number(acct.created) || null, memberId: acct.memberId || null }; + return { email: acct.email, username: acct.username || null, wallet: acct.address || null, sponsorEmail, joinedAt: Number(acct.created) || null, memberId: acct.memberId || null, profile: profileOf(acct) }; } -const hashOf = r => crypto.createHash('sha1').update([r.username || '', r.wallet || '', r.sponsorEmail || '', r.joinedAt || '', r.memberId || ''].join('|')).digest('hex').slice(0, 16); +// the member's profile travels too (Marty 2026-10-11: no re-typing on LinkSpin; they can change it there later). Avatar as an +// absolute https URL so the other property can show it; socials as the parsed {platform: url} object. +const PUBLIC = () => String(process.env.PUBLIC_URL || 'https://instantadpay.com').replace(/\/+$/, ''); +function profileOf(a) { + let socials = null; try { socials = a.socials ? (typeof a.socials === 'string' ? JSON.parse(a.socials) : a.socials) : null; } catch (e) { socials = null; } + const av = String(a.avatarUrl || '').trim(); + const avatarUrl = !av ? null : /^https:\/\//i.test(av) ? av : av.startsWith('/') ? PUBLIC() + av : null; + const bio = String(a.bio || '').trim().slice(0, 600) || null; + if (!avatarUrl && !bio && !(socials && Object.keys(socials).length)) return null; + return { avatarUrl, bio, socials: socials && Object.keys(socials).length ? socials : null }; +} +const hashOf = r => crypto.createHash('sha1').update([r.username || '', r.wallet || '', r.sponsorEmail || '', r.joinedAt || '', r.memberId || '', r.profile ? JSON.stringify(r.profile) : ''].join('|')).digest('hex').slice(0, 16); async function post(rows) { const raw = JSON.stringify({ rows }); const ts = String(Date.now());