mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
feat(security&privacy) : update the save address algorithm
This commit is contained in:
+13
-4
@@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user