diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index 4cac18b2..e248e046 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -521,4 +521,5 @@
Pick %1$s more
Not enough people for a group yet.
A group needs at least two other people, and everyone in it is added when it's made. To talk with one person, start a chat with them instead.
+ Run by %1$s alone. Changes to this group don't need anyone else's approval.
diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/ChatRoomDetailScreen.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/ChatRoomDetailScreen.kt
index e9623642..5e6fc129 100644
--- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/ChatRoomDetailScreen.kt
+++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/composable/ChatRoomDetailScreen.kt
@@ -86,6 +86,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey
import mobi.giza.compose.ui.theme.spacing
import mobi.giza.compose.resources.every_member_of_this_group_administers_it_there
import mobi.giza.compose.resources.admin_room
+import mobi.giza.compose.resources.run_by_alone
import mobi.giza.compose.resources.founding_members_have_no_key_package
import mobi.giza.compose.resources.founding_members_invited
import mobi.giza.compose.resources.invite_them
@@ -928,6 +929,19 @@ fun ChatRoomDetailScreen(
}
}
+ // A group run by one person, which Giza no longer makes: said
+ // above its members, because nothing else here explains why it
+ // behaves unlike every other group the member is in.
+ chatRoomDetailUIState.soleAdminName?.let { soleAdminName ->
+ item {
+ Text(
+ text = stringResource(Res.string.run_by_alone, soleAdminName),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ }
+
if (chatRoomDetailUIState.canInvite) item {
TextButton(
onClick = {
diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/ChatRoomDetailViewModel.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/ChatRoomDetailViewModel.kt
index 8332bb3f..56842304 100644
--- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/ChatRoomDetailViewModel.kt
+++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/model/ChatRoomDetailViewModel.kt
@@ -10,6 +10,7 @@ import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import co.touchlab.kermit.Logger
+import com.vitorpamplona.marmot.groups.currentAdminIdentities
import com.vitorpamplona.marmot.groups.currentGroupState
import com.vitorpamplona.marmot.groups.isLocalAdmin
import com.vitorpamplona.quartz.nip01Core.core.Event
@@ -135,12 +136,36 @@ class ChatRoomDetailViewModel(
?: publicKey.take(SHORTENED_PUBLIC_KEY_LENGTH)
},
adminRoomId = if (localChatRoom.chatRoom.mlsGroupState == null) chatRepository.adminRoomOf(chatRoomId) else null,
+ soleAdminName = soleAdminOf(localChatRoom, hasKey = groupKeyState != null)?.let { publicKey ->
+ nostrRepository.getProfileWithPublicKey(publicKey)?.humanReadableNameOrPubkey()
+ ?: publicKey.take(SHORTENED_PUBLIC_KEY_LENGTH)
+ },
)
}
localChatRoom?.let { observeShares(it.chatRoom.id) }
}
}
+ /**
+ * The one admin of a group run by one person, or null. Every group Giza makes
+ * is robust now, so this only finds groups made before that or by a Bennu peer;
+ * nothing else on the screen says why such a group behaves unlike the others.
+ * docs/remove-convenient-groups.md, Phase 5.
+ */
+ private fun soleAdminOf(localChatRoom: LocalChatRoom, hasKey: Boolean): HexKey? {
+ if (hasKey) return null
+
+ val members = localChatRoom.localParticipants.count { it.participant.deletedAt == null }
+ if (members <= 2) return null
+
+ val admins = runCatching { localChatRoom.chatRoom.toMlsGroup()?.currentAdminIdentities() }
+ .onFailure { logger.w("Couldn't read the admins of ${localChatRoom.chatRoom.id}", it) }
+ .getOrNull()
+ ?: return null
+
+ return admins.singleOrNull()
+ }
+
private var sharesObserver: Job? = null
/**
diff --git a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/ChatRoomDetailUIState.kt b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/ChatRoomDetailUIState.kt
index 34a6c6a9..ca658017 100755
--- a/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/ChatRoomDetailUIState.kt
+++ b/composeApp/src/commonMain/kotlin/mobi/giza/compose/ui/view/state/ChatRoomDetailUIState.kt
@@ -118,6 +118,14 @@ sealed interface ChatRoomDetailUIState {
* Phase 5.
*/
val adminRoomId: String? = null,
+ /**
+ * Who runs this group alone, when it is one: a Marmot room with no key
+ * behind it, more than two members and one admin -- a group made before
+ * every group was robust, or one a Bennu peer made. Null for every other
+ * room, a one-to-one chat included, since one person running a chat for
+ * two is not news. docs/remove-convenient-groups.md, Phase 5.
+ */
+ val soleAdminName: String? = null,
): ChatRoomDetailUIState
data class Error(
diff --git a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/RobustGroupAdminsJvmTest.kt b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/RobustGroupAdminsJvmTest.kt
index 99d6a32b..bed62b48 100644
--- a/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/RobustGroupAdminsJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/mobi/giza/compose/managers/RobustGroupAdminsJvmTest.kt
@@ -394,4 +394,65 @@ class RobustGroupAdminsJvmTest {
}
}
}
+
+ // ---- A group run by one person ------------------------------------------------
+
+ /**
+ * Giza stops making groups its creator runs alone, and does not stop joining
+ * them. docs/remove-convenient-groups.md, D4: a Bennu member still makes them,
+ * and a Giza member invited to one takes part like anybody else.
+ *
+ * Made with one admin and a random id -- no key behind it -- which is all a
+ * "convenient" group ever was on the wire.
+ */
+ @Test
+ fun `a group its creator runs alone, made elsewhere, is still joined`(): Unit = runBlocking {
+ listOf(MarmotProfile.LEGACY, MarmotProfile.CURRENT).forEach { profile ->
+ val phones = List(3) { Phone(profile) }
+ try {
+ phones.forEach { it.ready() }
+ phones.forEach { phone -> phones.forEach { MarmotStandIn.seedProfile(phone.db, it.publicKey) } }
+ val creator = phones.first()
+ phones.drop(1).forEach { creator.db.marmotKeyPackageDao().upsert(it.keyPackage) }
+
+ val soloRoomId = KeyPair().pubKey.toHexKey()
+ val outcome = MarmotGroupCreation.create(
+ database = creator.db,
+ chatRepository = creator.chatRepository,
+ groupId = soloRoomId,
+ name = "Checkers",
+ purpose = "Run by its creator.",
+ adminPublicKeys = setOf(creator.publicKey),
+ userPublicKey = creator.publicKey,
+ keyPair = creator.keyPair,
+ keyPackageLookupTimeout = 2_000L,
+ profile = profile,
+ )
+ assertIs(outcome, "($profile)")
+
+ // `create` invites the admins it is given, and here that is nobody but
+ // the creator. The members come the way a creator-run group's always
+ // did: one founding commit for all of them.
+ val room = assertNotNull(creator.db.chatRoomDao().findChatRoomById(soloRoomId), "($profile)")
+ val notAdded = creator.chatRepository.addMembers(room, phones.drop(1).map { it.publicKey to it.keyPackage })
+ assertTrue(notAdded.isEmpty(), "the creator could not invite $notAdded ($profile)")
+
+ phones.drop(1).forEach { joiner ->
+ welcome(from = creator, to = joiner, roomId = soloRoomId)
+
+ val room = assertNotNull(joiner.db.chatRoomDao().findChatRoomById(soloRoomId), "$joiner has no room ($profile)")
+ val group = assertNotNull(room.chatRoom.toMlsGroup(), "$joiner holds no group ($profile)")
+ assertEquals(setOf(creator.publicKey), group.currentAdminIdentities(), "$joiner's admin policy ($profile)")
+ assertFalse(group.isLocalAdmin(), "$joiner is not an admin of a room its creator runs ($profile)")
+ assertEquals(
+ FoundingAdmins.Check.NotKeyBacked,
+ FoundingAdmins.check(joiner.db, soloRoomId),
+ "no key behind it, so no founders to check ($profile)",
+ )
+ }
+ } finally {
+ phones.forEach { it.close() }
+ }
+ }
+ }
}