Skip to content

Commit

Permalink
on Account rename, rename mutes only after successful merge of the ch…
Browse files Browse the repository at this point in the history
…ange to the backing storage
  • Loading branch information
hoijui committed Jan 27, 2011
1 parent 53dda4f commit d060fef
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,11 @@ public boolean process(Client client, List<String> args)
}

Account acc = getContext().getAccountsService().findAccountNoCase(newUsername);
if (acc != null && acc != client.getAccount()) {
if ((acc != null) && (acc != client.getAccount())) {
client.sendLine("SERVERMSG RENAMEACCOUNT failed: Account with same username already exists!");
return false;
}

// make sure all mutes are accordingly adjusted to new userName:
for (int i = 0; i < getContext().getChannels().getChannelsSize(); i++) {
getContext().getChannels().getChannel(i).getMuteList().rename(client.getAccount().getName(), newUsername);
}

final String oldName = client.getAccount().getName();
Account accountNew = client.getAccount().clone();
accountNew.setName(newUsername);
Expand All @@ -92,6 +87,11 @@ public boolean process(Client client, List<String> args)
return false;
}

// make sure all mutes are accordingly adjusted to the new userName:
for (int i = 0; i < getContext().getChannels().getChannelsSize(); i++) {
getContext().getChannels().getChannel(i).getMuteList().rename(client.getAccount().getName(), newUsername);
}

client.sendLine(new StringBuilder("SERVERMSG Your account has been renamed to <")
.append(accountNew.getName())
.append(">. Reconnect with new account (you will now be automatically disconnected)!").toString());
Expand Down

0 comments on commit d060fef

Please sign in to comment.