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:
Jannis Braun
2026-04-03 05:27:51 +02:00
parent 02a44c201d
commit 1a2bc0ec52
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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));