feat(security&privacy) : update the save address algorithm
This commit is contained in:
parent
755ddcbf47
commit
8a90770072
1 changed files with 13 additions and 4 deletions
|
|
@ -107,15 +107,24 @@ class EditRoomAddressPresenter @AssistedInject constructor(
|
||||||
if (savedAliasFromHomeserver != null) {
|
if (savedAliasFromHomeserver != null) {
|
||||||
room.removeRoomAliasFromRoomDirectory(savedAliasFromHomeserver).getOrThrow()
|
room.removeRoomAliasFromRoomDirectory(savedAliasFromHomeserver).getOrThrow()
|
||||||
}
|
}
|
||||||
// Finally update the canonical alias state..
|
|
||||||
|
// Finally update the canonical alias state
|
||||||
when {
|
when {
|
||||||
// Allow to update the canonical alias only if the saved canonical alias matches the homeserver or if there is no canonical alias
|
// Allow to update the canonical alias only if the saved canonical alias matches the homeserver or if there is no canonical alias
|
||||||
savedCanonicalAlias == null || savedCanonicalAlias.matchesServer(serverName) -> {
|
savedCanonicalAlias == null || savedCanonicalAlias.matchesServer(serverName) -> {
|
||||||
room.updateCanonicalAlias(newRoomAlias, room.alternativeAliases).getOrThrow()
|
val newAlternativeAliases = room.alternativeAliases.filter { it != savedAliasFromHomeserver }
|
||||||
|
room.updateCanonicalAlias(newRoomAlias, newAlternativeAliases).getOrThrow()
|
||||||
}
|
}
|
||||||
// Otherwise, update the alternative aliases and keep the current canonical alias
|
// Otherwise, only update the alternative aliases and keep the current canonical alias
|
||||||
else -> {
|
else -> {
|
||||||
val newAlternativeAliases = listOf(newRoomAlias) + room.alternativeAliases
|
val newAlternativeAliases = buildList {
|
||||||
|
add(newRoomAlias)
|
||||||
|
for (alias in room.alternativeAliases) {
|
||||||
|
if (alias != savedAliasFromHomeserver) {
|
||||||
|
add(alias)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
room.updateCanonicalAlias(savedCanonicalAlias, newAlternativeAliases).getOrThrow()
|
room.updateCanonicalAlias(savedCanonicalAlias, newAlternativeAliases).getOrThrow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue