LinkSpin sync: carry the member profile (avatar, bio, social links) with each row

Marty 2026-10-11: members should not re-type their profile on LinkSpin. Rows now
include profile {avatarUrl (absolute https), bio, socials}; it is part of the row
hash so every profiled member re-syncs once, and a profile edit touches the sync.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-11 06:40:05 -05:00
parent 23da5b61ba
commit a6c523c6aa
2 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -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)),
+13 -2
View File
@@ -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());