fix: use timestamp 0 for never-edited profiles in LWW comparisons
profileUpdatedAt ?? createdAt treated freshly registered users as having "newer" profiles than users with real edit history, because createdAt is always NOW at registration time. This broke federation profile sync: the client correctly pushed home → remote, but the remote server's LWW guard rejected the write (stored createdAt > incoming profileUpdatedAt). A null profileUpdatedAt means "never edited" — that's timestamp 0, not the user's creation time.
This commit is contained in:
@@ -361,7 +361,7 @@ export async function userRoutes(app: FastifyInstance): Promise<void> {
|
||||
if (profileUpdatedAt !== undefined && typeof profileUpdatedAt === 'number') {
|
||||
const currentUser = db.select().from(schema.users).where(eq(schema.users.id, request.userId)).get();
|
||||
if (currentUser) {
|
||||
const storedTs = currentUser.profileUpdatedAt ?? currentUser.createdAt;
|
||||
const storedTs = currentUser.profileUpdatedAt ?? 0;
|
||||
if (profileUpdatedAt < storedTs) {
|
||||
// Incoming data is older — return current state without updating
|
||||
return reply.code(200).send(sanitizeUser(currentUser, true));
|
||||
|
||||
@@ -49,7 +49,7 @@ export function sanitizeUser(row: typeof schema.users.$inferSelect, isSelf = fal
|
||||
customStatus: row.customStatus,
|
||||
isAdmin: row.isAdmin === 1,
|
||||
discoverable: row.discoverable !== 0,
|
||||
profileUpdatedAt: row.profileUpdatedAt ?? row.createdAt,
|
||||
profileUpdatedAt: row.profileUpdatedAt ?? 0,
|
||||
createdAt: row.createdAt,
|
||||
homeInstance: row.homeInstance ?? null,
|
||||
homeUserId: row.homeUserId ?? null,
|
||||
|
||||
Reference in New Issue
Block a user