feat: add removeMemberFromGroup and updateGroupMetadata to AccountViewModel
- Wire removeMember through AccountViewModel for UI access - Add updateGroupMetadata to MlsGroupManager with Mutex protection https://claude.ai/code/session_018gVkmmYgMFtBH7G31pCk9N
This commit is contained in:
+4
-2
@@ -1480,8 +1480,10 @@ class AccountViewModel(
|
||||
val groupRelays =
|
||||
metadata
|
||||
?.relays
|
||||
?.mapNotNull { com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer.normalizeOrNull(it) }
|
||||
?.toSet()
|
||||
?.mapNotNull {
|
||||
com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
|
||||
.normalizeOrNull(it)
|
||||
}?.toSet()
|
||||
return if (!groupRelays.isNullOrEmpty()) groupRelays else account.outboxRelays.flow.value
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -27,6 +27,7 @@ import com.vitorpamplona.quartz.marmot.mls.messages.CommitResult
|
||||
import com.vitorpamplona.quartz.marmot.mls.messages.KeyPackageBundle
|
||||
import com.vitorpamplona.quartz.marmot.mls.schedule.KeySchedule
|
||||
import com.vitorpamplona.quartz.marmot.mls.schedule.SecretTree
|
||||
import com.vitorpamplona.quartz.marmot.mls.tree.Extension
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.utils.Log
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
@@ -368,6 +369,23 @@ class MlsGroupManager(
|
||||
result
|
||||
}
|
||||
|
||||
/**
|
||||
* Update group extensions (e.g., MIP-01 metadata) via a GroupContextExtensions proposal.
|
||||
* Creates the proposal, commits it, and persists the new state.
|
||||
*/
|
||||
suspend fun updateGroupExtensions(
|
||||
nostrGroupId: HexKey,
|
||||
extensions: List<Extension>,
|
||||
): CommitResult =
|
||||
mutex.withLock {
|
||||
val group = requireGroup(nostrGroupId)
|
||||
retainEpochSecrets(nostrGroupId, group)
|
||||
group.proposeGroupContextExtensions(extensions)
|
||||
val result = group.commit()
|
||||
persistGroup(nostrGroupId)
|
||||
result
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave a group (self-remove).
|
||||
* Returns the SelfRemove proposal bytes to publish, then removes
|
||||
|
||||
Reference in New Issue
Block a user