feat: store and send a group's bare name (group-name-braces, Phase 2)
A room is created, signed into a birth certificate and joined from a Welcome under its bare name; the braces are only drawn. MarmotGroupName.of and the stored & are gone, and v53's spec applies bare, so a device upgrading from before v53 goes straight to bare names. The subgroup-certified line is written with the name drawn in braces (D6), moved up from Phase 4 because it was the last caller of of(). The two duplicate-name checks compare names bare, so a room still stored as &Ekklesia is taken by a typed Ekklesia (D8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
916b5c35ef
commit
cc64856c88
18 files changed
+142
-110
No files matched your search
@@ -877,12 +877,13 @@ abstract class NostrDao(
|
||||
ChatRoom(
|
||||
id = nostrGroupId,
|
||||
userPublicKey = userPublicKey,
|
||||
// Under the same rule as a room this device
|
||||
// makes, whoever made this one: an older Giza or
|
||||
// a Bennu peer wrote `#name`, another client a
|
||||
// bare name. The group's own state keeps what its
|
||||
// creator wrote. docs/group-name-prefix.md, D4.
|
||||
subject = group.roomName()?.let(MarmotGroupName::of),
|
||||
// Bare, as a room this device makes is, whoever
|
||||
// made this one: an older Giza wrote `&name`, a
|
||||
// Bennu peer `#name`, another client a bare name.
|
||||
// The braces are drawn, never stored, and the
|
||||
// group's own state keeps what its creator wrote.
|
||||
// docs/group-name-braces.md, D4.
|
||||
subject = group.roomName()?.let(MarmotGroupName::bare),
|
||||
description = group.roomDescription(),
|
||||
initialGiftWrapPayloadId = decryptedGiftWrapPayload.id,
|
||||
createdAt = decryptedGiftWrapPayload.createdAt,
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import mobi.giza.compose.managers.MarmotGroupName
|
||||
* the only thing the app ever shows, becomes `&name`. A room joined after this has the rule
|
||||
* applied as its Welcome is processed, so nothing has to run twice.
|
||||
*
|
||||
* The rule runs here in Kotlin, through [MarmotGroupName.of], rather than as an `ltrim` in
|
||||
* The rule runs here in Kotlin, through [MarmotGroupName.bare], rather than as an `ltrim` in
|
||||
* SQL, so this is the same function the rest of the app names rooms with and not a copy of
|
||||
* it that can drift. A room with a bare name, from a client that marks nothing, gets the
|
||||
* mark here for the same reason a Welcome gives it one.
|
||||
@@ -32,7 +32,7 @@ class MarmotGroupNameMigrationSpec : AutoMigrationSpec {
|
||||
buildList {
|
||||
while (statement.step()) {
|
||||
val subject = statement.getText(1)
|
||||
val named = MarmotGroupName.of(subject)
|
||||
val named = MarmotGroupName.bare(subject)
|
||||
if (named != subject) add(statement.getText(0) to named)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1436,9 +1436,11 @@ data class ChatMessage(
|
||||
// The name is the one the parent certified, which is the only one
|
||||
// that was ever put to this room -- the child may since have been
|
||||
// renamed, and this line is a record of what was agreed rather
|
||||
// than a view of what is. It is written under today's mark,
|
||||
// though: a certificate signed as `#name` before
|
||||
// docs/group-name-prefix.md certified the name, not the `#`.
|
||||
// than a view of what is. The name is drawn into the sentence
|
||||
// in braces as it is written, whatever mark the certificate was
|
||||
// signed under: it certified the name, not the punctuation. The
|
||||
// one place braces reach the disk, inside a sentence and never in
|
||||
// a name column (docs/group-name-braces.md, D6).
|
||||
SubgroupBirthCertificateEvent.KIND -> {
|
||||
SubgroupManager.record(
|
||||
database = database,
|
||||
@@ -1446,7 +1448,7 @@ data class ChatMessage(
|
||||
innerEvent = event
|
||||
) ?: return null
|
||||
|
||||
val name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::of)
|
||||
val name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::display)
|
||||
val admins = SubgroupBirthCertificateEvent.parseAdminPublicKeys(event.tags).size
|
||||
|
||||
ChatMessage(
|
||||
|
||||
+2
-2
@@ -91,8 +91,8 @@ object CeremonyFollowThrough {
|
||||
|
||||
/**
|
||||
* What a ceremony's room is called: the name the coordinator gave a subgroup,
|
||||
* or the name of the group an admin room administers. The bare name; the
|
||||
* room puts it under `MarmotGroupName`.
|
||||
* or the name of the group an admin room administers. The bare name, as the
|
||||
* room stores it; the braces are drawn (docs/group-name-braces.md).
|
||||
*/
|
||||
fun roomName(session: DkgSession): String =
|
||||
session.subject ?: if (session.parentChatRoomId != null) "Subgroup" else "Group"
|
||||
|
||||
+5
-3
@@ -376,10 +376,12 @@ object ChillDkgRitualManager {
|
||||
|
||||
/**
|
||||
* Whether two group names are the same name, as far as folding a repeated ask
|
||||
* goes: trimmed, and without regard to case. Names are not identities, so this
|
||||
* decides nothing but whether an ask is a repeat.
|
||||
* goes: bare, and without regard to case. Bare, so a room still stored under an old
|
||||
* mark (`&Ekklesia`) is the same name as an ask for `Ekklesia`
|
||||
* (docs/group-name-braces.md, D8). Names are not identities, so this decides
|
||||
* nothing but whether an ask is a repeat.
|
||||
*/
|
||||
private fun sameName(name: String): String = name.trim().lowercase()
|
||||
private fun sameName(name: String): String = MarmotGroupName.bare(name).lowercase()
|
||||
|
||||
/**
|
||||
* Feeds one inbound ritual message in and advances the ritual as far as it
|
||||
|
||||
@@ -97,10 +97,11 @@ object MarmotGroupCreation {
|
||||
* the verified value off the child's own key state -- never a claim off a
|
||||
* proposal.
|
||||
*
|
||||
* [name] is put under [MarmotGroupName] here rather than trusted from the
|
||||
* caller. Every Marmot room on a device is an `&name`, and this is the funnel
|
||||
* both flows that make one already go through, so it is the one place the
|
||||
* convention cannot be forgotten.
|
||||
* [name] is made [MarmotGroupName.bare] here rather than trusted from the
|
||||
* caller: the room is stored and sent under its bare name, and drawn in
|
||||
* braces (docs/group-name-braces.md). This is the funnel both flows that make
|
||||
* one already go through, so it is the one place a stray mark -- one typed, or
|
||||
* one carried over from a name minted under `&` -- cannot get in.
|
||||
*/
|
||||
suspend fun create(
|
||||
database: GizaDatabase,
|
||||
@@ -121,7 +122,7 @@ object MarmotGroupCreation {
|
||||
// A confederation has no room of its own (docs/confederation-room-removal.md, D11).
|
||||
if (ConfederationFormation.isConfederation(database, groupId)) return Outcome.Failed("A confederation has no room of its own")
|
||||
|
||||
val groupName = MarmotGroupName.of(name)
|
||||
val groupName = MarmotGroupName.bare(name)
|
||||
|
||||
val peers = adminPublicKeys.filterNot { it == userPublicKey }
|
||||
val keyPackages = keyPackagesFor(chatRepository, peers, keyPackageLookupTimeout, profile)
|
||||
|
||||
@@ -33,12 +33,6 @@ object MarmotGroupName {
|
||||
/** Drawn after the name, and shown at the trailing edge of a name field. */
|
||||
const val SUFFIX = "}"
|
||||
|
||||
/**
|
||||
* The mark stored in front of a Marmot room's name before docs/group-name-braces.md.
|
||||
* Still written by [of] until the writers store the bare name.
|
||||
*/
|
||||
private const val LEGACY_PREFIX = "&"
|
||||
|
||||
/**
|
||||
* Every mark a Marmot room's name has been stored with: the `&` of
|
||||
* docs/group-name-prefix.md and the `#` before it. Rooms minted under them still
|
||||
@@ -53,6 +47,11 @@ object MarmotGroupName {
|
||||
* what lets one function name the rooms a Welcome brings in, the rooms already on a
|
||||
* device, and the names old certificates carry.
|
||||
*
|
||||
* Idempotence matters for one more reason. A subgroup's name is made bare twice from
|
||||
* the same subject by two unrelated callers -- once into the birth certificate the
|
||||
* parent's quorum signs, once onto the room itself -- and those two have to be the
|
||||
* same string, or the room is not called what its parent certified.
|
||||
*
|
||||
* Only a *leading* mark is a mark: `Arts & crafts` keeps its `&`. A blank name, or one
|
||||
* that is only marks, is handed back trimmed rather than made up.
|
||||
*/
|
||||
@@ -67,18 +66,4 @@ object MarmotGroupName {
|
||||
val bare = NameMarks.strip(name, LEGACY_MARKS)
|
||||
return if (bare.isEmpty()) name.trim() else PREFIX + bare + SUFFIX
|
||||
}
|
||||
|
||||
/**
|
||||
* [name] under the stored `&` of docs/group-name-prefix.md: what the writers still
|
||||
* store until docs/group-name-braces.md's Phase 2 has them store [bare].
|
||||
*
|
||||
* Idempotent on purpose. A subgroup's name is normalised twice from the same bare
|
||||
* subject and by two unrelated callers -- once into the birth certificate the
|
||||
* parent's quorum signs, once onto the room itself -- and those two have to be the
|
||||
* same string, or the room is not called what its parent certified.
|
||||
*/
|
||||
fun of(name: String): String {
|
||||
val bare = NameMarks.strip(name, LEGACY_MARKS)
|
||||
return if (bare.isEmpty()) name.trim() else LEGACY_PREFIX + bare
|
||||
}
|
||||
}
|
||||
@@ -229,10 +229,10 @@ object SubgroupManager {
|
||||
require(name.isNotBlank()) { "A subgroup has to be called something" }
|
||||
|
||||
// The certificate is a signature over the name, so it has to be the name
|
||||
// the room ends up with. `MarmotGroupCreation` normalises again on the
|
||||
// way in and `MarmotGroupName.of` is idempotent, so the two agree by
|
||||
// the room ends up with. `MarmotGroupCreation` makes it bare again on the
|
||||
// way in and `MarmotGroupName.bare` is idempotent, so the two agree by
|
||||
// construction rather than by both callers remembering.
|
||||
val subgroupName = MarmotGroupName.of(name)
|
||||
val subgroupName = MarmotGroupName.bare(name)
|
||||
|
||||
// One certificate per child. A second is a `d`-tag replacement of the
|
||||
// first rather than a second subgroup, and spending a quorum's attention
|
||||
@@ -444,11 +444,11 @@ object SubgroupManager {
|
||||
chatRoomId = chatRoomId,
|
||||
parentChatRoomId = parentChatRoomId,
|
||||
certificate = signed,
|
||||
// Under today's mark: a certificate signed before
|
||||
// docs/group-name-prefix.md says `#name`, and the room it
|
||||
// names is `&name` on this device. What was agreed is the
|
||||
// name, not the punctuation.
|
||||
name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::of),
|
||||
// Bare, as every stored name is: a certificate signed before
|
||||
// docs/group-name-braces.md says `&name`, or `#name` before
|
||||
// that. What was agreed is the name, not the punctuation, and
|
||||
// the screen that lists it draws the braces.
|
||||
name = SubgroupBirthCertificateEvent.parseName(event.tags)?.let(MarmotGroupName::bare),
|
||||
adminPublicKeys = SubgroupBirthCertificateEvent.parseAdminPublicKeys(event.tags),
|
||||
room = database.chatRoomDao().findChatRoomById(chatRoomId),
|
||||
keyState = database.groupKeyStateDao().getByChatRoomId(chatRoomId),
|
||||
|
||||
@@ -69,11 +69,12 @@ object ProposedEvent {
|
||||
SubgroupBirthCertificateEvent.KIND -> Summary(
|
||||
label = "A new subgroup of this group",
|
||||
detail = listOfNotNull(
|
||||
// Verbatim, not through `MarmotGroupName.of`: this is what the
|
||||
// signer is about to approve, and a certificate proposed before
|
||||
// docs/group-name-prefix.md says `#name`. The summary of a
|
||||
// signature shows the bytes being signed, even where the rest
|
||||
// of the app would show the name under today's mark (D5).
|
||||
// Verbatim, neither made bare nor drawn in braces: this is what
|
||||
// the signer is about to approve, and a certificate proposed
|
||||
// before docs/group-name-braces.md says `&name` (or `#name`,
|
||||
// before docs/group-name-prefix.md). The summary of a signature
|
||||
// shows the bytes being signed, even where the rest of the app
|
||||
// draws the name in braces (docs/group-name-braces.md, D5).
|
||||
SubgroupBirthCertificateEvent.parseName(event.tags),
|
||||
SubgroupBirthCertificateEvent.parseAdminPublicKeys(event.tags)
|
||||
.size
|
||||
|
||||
+10
-10
@@ -74,11 +74,11 @@ class SelectSubgroupAdminsViewModel(
|
||||
/**
|
||||
* What the coordinator typed, bare.
|
||||
*
|
||||
* The `&` is drawn beside the field rather than pushed into this state:
|
||||
* normalising on every keystroke would move the caret out from under somebody
|
||||
* halfway through a word. It is added by `MarmotGroupName.of` where the
|
||||
* subgroup's name is actually used -- in the certificate the parent signs and
|
||||
* on the room itself -- which is idempotent, so the two agree.
|
||||
* The braces are drawn around the field, never pushed into this state, and
|
||||
* never stored: what is typed is the name. Any mark somebody types anyway is
|
||||
* taken off by `MarmotGroupName.bare` where the subgroup's name is used -- in
|
||||
* the certificate the parent signs and on the room itself -- which is
|
||||
* idempotent, so the two agree (docs/group-name-braces.md).
|
||||
*/
|
||||
val name: MutableState<String> = mutableStateOf("")
|
||||
|
||||
@@ -266,11 +266,11 @@ class SelectSubgroupAdminsViewModel(
|
||||
return@launch
|
||||
}
|
||||
|
||||
// The bare name goes on the ceremony, and the `&` is added where the
|
||||
// name is used: `proposeBirthCertificate` normalises the name the
|
||||
// parent signs and `MarmotGroupCreation` normalises the name the room
|
||||
// carries, both reading it back off this session.
|
||||
// `MarmotGroupName.of` is idempotent, so those are the same string --
|
||||
// The bare name goes on the ceremony, and on everything after it:
|
||||
// `proposeBirthCertificate` makes bare the name the parent signs and
|
||||
// `MarmotGroupCreation` the name the room carries, both reading it
|
||||
// back off this session.
|
||||
// `MarmotGroupName.bare` is idempotent, so those are the same string --
|
||||
// which they have to be, or the room is not called what its parent
|
||||
// certified.
|
||||
//
|
||||
|
||||
+7
-2
@@ -1,6 +1,7 @@
|
||||
package mobi.giza.compose.ui.view.state
|
||||
|
||||
import mobi.giza.compose.database.model.Profile
|
||||
import mobi.giza.compose.managers.MarmotGroupName
|
||||
|
||||
sealed interface SelectQuorumUIState {
|
||||
data class Loaded(
|
||||
@@ -16,9 +17,13 @@ sealed interface SelectQuorumUIState {
|
||||
*/
|
||||
val existingGroups: List<ExistingGroup> = emptyList(),
|
||||
): SelectQuorumUIState {
|
||||
/** Whether the group being made would share its name with one of [existingGroups]. */
|
||||
/**
|
||||
* Whether the group being made would share its name with one of [existingGroups]:
|
||||
* compared bare, so a room still stored under an old mark (`&Ekklesia`) is the same
|
||||
* name as a typed `Ekklesia` (docs/group-name-braces.md, D8).
|
||||
*/
|
||||
fun sharesNameWith(name: String): Boolean =
|
||||
existingGroups.any { it.name?.trim()?.equals(name.trim(), ignoreCase = true) == true }
|
||||
existingGroups.any { it.name?.let(MarmotGroupName::bare)?.equals(MarmotGroupName.bare(name), ignoreCase = true) == true }
|
||||
}
|
||||
|
||||
/** A group already made by the same people: its name, or null if it has none. */
|
||||
|
||||
@@ -70,13 +70,4 @@ class MarmotGroupNameTest {
|
||||
assertEquals(expected, MarmotGroupName.display(input), "display($input)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the stored mark is still the old one until the writers store bare`() {
|
||||
assertEquals("&Ekklesia", MarmotGroupName.of("Ekklesia"))
|
||||
assertEquals("&Ekklesia", MarmotGroupName.of("#Ekklesia"))
|
||||
assertEquals("&Ekklesia", MarmotGroupName.of("&Ekklesia"))
|
||||
assertEquals(MarmotGroupName.of("Translators"), MarmotGroupName.of(MarmotGroupName.of("Translators")))
|
||||
assertEquals("&", MarmotGroupName.of("&"))
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package mobi.giza.compose.ui.view.state
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
/**
|
||||
* A group's name is taken whatever mark it was stored under (docs/group-name-braces.md, D8).
|
||||
*
|
||||
* The `&` and `#` names are on purpose: rooms made before the braces were drawn were stored
|
||||
* under them, and a device that has not run v55 yet still holds them.
|
||||
*/
|
||||
class SelectQuorumNameTest {
|
||||
private fun loaded(vararg names: String?) =
|
||||
SelectQuorumUIState.Loaded(members = emptyList(), existingGroups = names.map { SelectQuorumUIState.ExistingGroup(it) })
|
||||
|
||||
@Test
|
||||
fun `a name stored under an old mark is the same name typed bare`() {
|
||||
assertTrue(loaded("&Ekklesia").sharesNameWith("Ekklesia"))
|
||||
assertTrue(loaded("#Ekklesia").sharesNameWith("ekklesia"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a name typed in braces is the same name stored bare`() {
|
||||
assertTrue(loaded("Ekklesia").sharesNameWith("{Ekklesia}"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a different name is not taken`() {
|
||||
assertFalse(loaded("Ekklesia", null).sharesNameWith("Agora"))
|
||||
}
|
||||
}
|
||||
+11
-7
@@ -14,6 +14,10 @@ import kotlin.test.assertEquals
|
||||
* The `#` subjects here are on purpose: they are what every Marmot room made before
|
||||
* docs/group-name-prefix.md was called, and what this migration exists to rename.
|
||||
*
|
||||
* v53 applies the *current* rule, so since docs/group-name-braces.md it stores the bare
|
||||
* name: a device upgrading from v52 or before goes straight to bare, and v55 then has
|
||||
* nothing to do.
|
||||
*
|
||||
* Run against the spec on a bare connection, the way `ChronicleRenameMigrationJvmTest` is:
|
||||
* the schema does not change, so Room's half of the migration is empty and this covers the
|
||||
* whole of what v53 does. The `ChatRoom` table is v52's, verbatim from `schemas/52.json`,
|
||||
@@ -66,27 +70,27 @@ class MarmotGroupNameMigrationJvmTest {
|
||||
|
||||
migrate()
|
||||
|
||||
assertEquals("&Ekklesia", subjectOf("ekklesia"))
|
||||
assertEquals("Ekklesia", subjectOf("ekklesia"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a group another client named without a mark gets one`() {
|
||||
fun `a group another client named without a mark is left as it is`() {
|
||||
createV52()
|
||||
insertRoom("polis", "Polis", marmot = true)
|
||||
|
||||
migrate()
|
||||
|
||||
assertEquals("&Polis", subjectOf("polis"))
|
||||
assertEquals("Polis", subjectOf("polis"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a group already under the mark is left as it is`() {
|
||||
fun `a group under the newer stored mark is made bare too`() {
|
||||
createV52()
|
||||
insertRoom("atlas", "&Atlas", marmot = true)
|
||||
|
||||
migrate()
|
||||
|
||||
assertEquals("&Atlas", subjectOf("atlas"))
|
||||
assertEquals("Atlas", subjectOf("atlas"))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +100,7 @@ class MarmotGroupNameMigrationJvmTest {
|
||||
|
||||
migrate()
|
||||
|
||||
assertEquals("&Agora", subjectOf("agora"))
|
||||
assertEquals("Agora", subjectOf("agora"))
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +132,7 @@ class MarmotGroupNameMigrationJvmTest {
|
||||
migrate()
|
||||
migrate()
|
||||
|
||||
assertEquals("&Ekklesia", subjectOf("ekklesia"))
|
||||
assertEquals("Ekklesia", subjectOf("ekklesia"))
|
||||
assertEquals("#topic", subjectOf("topic"))
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -212,10 +212,10 @@ class CurrentProfileKeyPackageJvmTest {
|
||||
|
||||
// The room is keyed on the routing id from the group's 0x8004 component, and its
|
||||
// restored state is a current-profile group that names the inviter as admin. The
|
||||
// client named it without a mark, and it is joined with one, as every Marmot room is
|
||||
// (docs/group-name-prefix.md, D4).
|
||||
// client named it without a mark, and it is stored bare, as every Marmot room is
|
||||
// (docs/group-name-braces.md, D4).
|
||||
val room = assertNotNull(db.chatRoomDao().findChatRoomById(routingId.toHexKey()), "no room was made for the routing id")
|
||||
assertEquals("&made elsewhere", room.chatRoom.subject)
|
||||
assertEquals("made elsewhere", room.chatRoom.subject)
|
||||
val restored = assertNotNull(room.chatRoom.toMlsGroup(), "the joined state does not restore")
|
||||
assertTrue(restored.currentGroupState().isCurrentProfile, "the restored group is not on the current profile")
|
||||
assertEquals(setOf(inviterHex), restored.currentAdminIdentities())
|
||||
|
||||
+6
-5
@@ -156,10 +156,11 @@ class MarmotGroupCreationJvmTest {
|
||||
val room = assertNotNull(db.chatRoomDao().findChatRoomById(groupId))
|
||||
val group = assertNotNull(room.chatRoom.toMlsGroup())
|
||||
|
||||
// Both, and the same string in each: the row is what this device draws in
|
||||
// its room list, and the group's own name is what every other member reads.
|
||||
assertEquals("&Ekklesia", room.chatRoom.subject)
|
||||
assertEquals("&Ekklesia", group.roomName())
|
||||
// Both, and the same bare string in each: the row is what this device draws
|
||||
// in its room list, and the group's own name is what every other member
|
||||
// reads. The braces are drawn, never stored (docs/group-name-braces.md).
|
||||
assertEquals("Ekklesia", room.chatRoom.subject)
|
||||
assertEquals("Ekklesia", group.roomName())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +271,7 @@ class MarmotGroupCreationJvmTest {
|
||||
)
|
||||
val created = assertIs<MarmotGroupCreation.Outcome.Created>(outcome)
|
||||
assertEquals(groupId, created.room.chatRoom.id, "the room is not the one the key derives")
|
||||
assertEquals("&Ekklesia", created.room.chatRoom.subject)
|
||||
assertEquals("Ekklesia", created.room.chatRoom.subject)
|
||||
|
||||
val group = assertNotNull(created.room.chatRoom.toMlsGroup())
|
||||
assertEquals(founders, group.currentAdminIdentities(), "${owner.pubKey.toHexKey().take(8)}'s room")
|
||||
|
||||
+19
-12
@@ -15,12 +15,13 @@ import mobi.giza.compose.database.builder.getRoomDatabase
|
||||
import mobi.giza.compose.database.repository.DatabaseMarmotRepository
|
||||
|
||||
/**
|
||||
* A room joined from a Welcome is called by the same rule as a room this device made.
|
||||
* A room joined from a Welcome is stored by the same rule as a room this device made: bare.
|
||||
*
|
||||
* The name a Welcome carries is whatever its creator wrote: `#name` from an older Giza or a
|
||||
* Bennu peer, a bare name from a client that marks nothing, `&name` from a Giza on the
|
||||
* current rule. Each of them is a Marmot room, and each lands as `&name`, so the mark on a
|
||||
* row says the same thing whoever made the room. docs/group-name-prefix.md, Phase 2.
|
||||
* The name a Welcome carries is whatever its creator wrote: `#name` from a Bennu peer,
|
||||
* `&name` from an older Giza, a bare name from a client that marks nothing or from a Giza
|
||||
* on the current rule. Each of them is a Marmot room, and each is stored as `name` and drawn
|
||||
* as `{name}`, so the mark on a row says the same thing whoever made the room.
|
||||
* docs/group-name-braces.md, Phase 2.
|
||||
*
|
||||
* The group is made and the invite sent by the library's own client, so the name reaches the
|
||||
* app through the same Welcome path a real peer's would.
|
||||
@@ -49,19 +50,25 @@ class MarmotGroupNameWelcomeJvmTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a room named under the old mark is joined under the new one`() = runBlocking {
|
||||
// `#` on purpose: what an older Giza or a Bennu peer still mints.
|
||||
assertEquals("&Ekklesia", joinedAs("#Ekklesia"))
|
||||
fun `a room Bennu named under the oldest mark is joined bare`() = runBlocking {
|
||||
// `#` on purpose: what a Bennu peer still mints.
|
||||
assertEquals("Ekklesia", joinedAs("#Ekklesia"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a room another client named without a mark is joined with one`() = runBlocking {
|
||||
assertEquals("&Ekklesia", joinedAs("Ekklesia"))
|
||||
fun `a room an older Giza named under its mark is joined bare`() = runBlocking {
|
||||
// `&` on purpose: what a Giza from before docs/group-name-braces.md mints.
|
||||
assertEquals("Ekklesia", joinedAs("&Ekklesia"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a room already under the mark is joined as it is`() = runBlocking {
|
||||
assertEquals("&Ekklesia", joinedAs("&Ekklesia"))
|
||||
fun `a room named without a mark is joined as it is`() = runBlocking {
|
||||
assertEquals("Ekklesia", joinedAs("Ekklesia"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `braces in a room's name are drawn, not stored`() = runBlocking {
|
||||
assertEquals("Ekklesia", joinedAs("{Ekklesia}"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -126,7 +126,7 @@ class SubgroupManagerJvmTest {
|
||||
|
||||
assertEquals(childRoomId, subgroup.chatRoomId)
|
||||
assertEquals(parentRoomId, subgroup.parentChatRoomId)
|
||||
assertEquals("&Translation team", subgroup.name)
|
||||
assertEquals("Translation team", subgroup.name)
|
||||
assertEquals(listOf(user, alice, bob), subgroup.adminPublicKeys)
|
||||
|
||||
// The whole point of reading certificates rather than rooms: this device
|
||||
@@ -148,7 +148,7 @@ class SubgroupManagerJvmTest {
|
||||
val signed = certificate(name = "#Translation team")
|
||||
record(signed)
|
||||
|
||||
assertEquals("&Translation team", SubgroupManager.subgroupsOf(db, parentRoomId).single().name)
|
||||
assertEquals("Translation team", SubgroupManager.subgroupsOf(db, parentRoomId).single().name)
|
||||
|
||||
// The kind:445 it arrived in, stored as sync stores one, so the inner event the line
|
||||
// is written from has a group event to hang off.
|
||||
@@ -198,7 +198,7 @@ class SubgroupManagerJvmTest {
|
||||
)
|
||||
)
|
||||
assertEquals(ChatMessage.TYPE_SUBGROUP_CERTIFIED, line.messageType)
|
||||
assertEquals("The group made &Translation team a subgroup, run by 3 of its members", line.content)
|
||||
assertEquals("The group made {Translation team} a subgroup, run by 3 of its members", line.content)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,7 +268,7 @@ class SubgroupManagerJvmTest {
|
||||
val subgroups = SubgroupManager.subgroupsOf(db, parentRoomId)
|
||||
|
||||
assertEquals(1, subgroups.size)
|
||||
assertEquals("&Second name", subgroups.single().name)
|
||||
assertEquals("Second name", subgroups.single().name)
|
||||
assertEquals(
|
||||
"Second name",
|
||||
SubgroupBirthCertificateEvent.parseName(
|
||||
@@ -538,10 +538,10 @@ class SubgroupManagerJvmTest {
|
||||
|
||||
// A quorum is being asked to sign a name, and `MarmotGroupCreation`
|
||||
// will name the room by the same rule from the same subject. If only
|
||||
// one of the two applied it, the parent would certify "Translation
|
||||
// team" and the room would be called "&Translation team".
|
||||
// one of the two applied it, the parent could certify "{Translation
|
||||
// team}" and the room be called "Translation team".
|
||||
assertEquals(
|
||||
MarmotGroupName.of("Translation team"),
|
||||
MarmotGroupName.bare("Translation team"),
|
||||
SubgroupBirthCertificateEvent.parseName(proposed.tags)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user