Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Undesirable message updates after user saving profile #17930

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/lib/server/functions/saveUserIdentity.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@ export function saveUserIdentity(userId, { _id, name: rawName, username: rawUser
const user = Users.findOneById(_id);

const previousUsername = user.username;
const previousName = user.name;
const nameChanged = previousName !== name;
const usernameChanged = previousUsername !== username;

if (typeof rawUsername !== 'undefined') {
if (typeof rawUsername !== 'undefined' && usernameChanged) {
if (!setUsername(_id, username, user)) {
return false;
}
user.username = username;
}

if (typeof rawName !== 'undefined') {
if (typeof rawName !== 'undefined' && nameChanged) {
if (!setRealName(_id, name, user)) {
return false;
}
}

// if coming from old username, update all references
if (previousUsername) {
if (previousUsername && usernameChanged) {
if (typeof rawUsername !== 'undefined') {
Messages.updateAllUsernamesByUserId(user._id, username);
Messages.updateUsernameOfEditByUserId(user._id, username);
Expand Down