feat(federation): preserve effective displayName across profile_update relay
FederationProfileUpdatePayload gains `username`: the home user's canonical handle. Receiver applies displayName ?? username so stubs whose home user has no displayName show the real handle instead of getting clobbered to null. Mirrors the existing fallback in hydrateReplicatedUserProfile. Username itself is immutable on the home instance, so the receiver does not rewrite the stub's username column on profile_update.
This commit is contained in:
@@ -5625,7 +5625,7 @@ async function downloadProfileAsset(
|
||||
}
|
||||
}
|
||||
|
||||
async function processProfileUpdateEvent(
|
||||
export async function processProfileUpdateEvent(
|
||||
event: FederationRelayEvent,
|
||||
sourceInstance: string,
|
||||
db: ReturnType<typeof getDb>,
|
||||
@@ -5717,10 +5717,17 @@ async function processProfileUpdateEvent(
|
||||
deleteUploadFile(oldBanner);
|
||||
}
|
||||
|
||||
// Authoritative overwrite — home instance is always right
|
||||
// Authoritative overwrite — home instance is always right.
|
||||
// displayName falls back to the home user's canonical username when null,
|
||||
// mirroring hydrateReplicatedUserProfile so stubs whose home user has no
|
||||
// displayName show the real handle instead of getting clobbered to null.
|
||||
// (The username field on the wire is the home's canonical handle, not the
|
||||
// stub's local-part; usernames are immutable on the home instance, so we
|
||||
// never rewrite the stub's username column here.)
|
||||
const effectiveDisplayName = payload.displayName ?? payload.username ?? null;
|
||||
db.update(schema.users)
|
||||
.set({
|
||||
displayName: payload.displayName,
|
||||
displayName: effectiveDisplayName,
|
||||
avatar: resolvedAvatar,
|
||||
banner: resolvedBanner,
|
||||
accentColor: payload.accentColor,
|
||||
|
||||
Reference in New Issue
Block a user