fix: Preserve existing values when optional update fields are omitted (#14344)

* fix: Preserve existing values when optional update fields are omitted

* chore: Rename setDefined to fill

* chore: Use fill in users.update and teamUpdater
This commit is contained in:
Tom Moor authored and GitHub committed 2026-10-26 17:29:17 -04:00
1 parent ce439c893c
commit 9fe0c7ba2b
18 files changed
+275 -136

No files matched your search

+9 -13
View File
@@ -287,28 +287,24 @@ router.post(
authorize(actor, "update", user);
const includeDetails = !!can(actor, "readDetails", user);
if (name) {
user.name = name;
}
if (avatarUrl !== undefined) {
user.avatarUrl = avatarUrl;
user.fill({
name: name || undefined,
avatarUrl,
language: language || undefined,
timezone: timezone || undefined,
});
// Mark that the user has manually changed their avatar
// This prevents automatic syncing from identity providers
// Mark that the user has manually changed their avatar
// This prevents automatic syncing from identity providers
if (avatarUrl !== undefined) {
user.setFlag(UserFlag.AvatarUpdated, avatarUrl ? true : false);
}
if (language) {
user.language = language;
}
if (preferences) {
user.preferences = {
...user.preferences,
...preferences,
};
}
if (timezone) {
user.timezone = timezone;
}
await user.saveWithCtx(ctx);