Don't broadcast commit when invite one other person
This commit is contained in:
1 parent
c39b26c2e1
commit
f1413d3b9b
1 file changed
+54
-53
+54
-53
@@ -171,59 +171,6 @@ abstract class MarmotOutboundDao(
|
|||||||
defenestratableMarmotRetainedEpochSecrets
|
defenestratableMarmotRetainedEpochSecrets
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommitEvent...
|
|
||||||
val encryptedContent = encryptedCommitEvent(
|
|
||||||
mlsGroup,
|
|
||||||
commitBytes = commitResult.framedCommitBytes,
|
|
||||||
exporterKey = commitResult.preCommitExporterSecret
|
|
||||||
)
|
|
||||||
|
|
||||||
val template = GroupEvent.build(
|
|
||||||
encryptedContentBase64 = encryptedContent,
|
|
||||||
nostrGroupId = nostrGroupId
|
|
||||||
)
|
|
||||||
|
|
||||||
val ephemeralSigner = NostrSignerInternal(KeyPair())
|
|
||||||
val commitEvent: GroupEvent = ephemeralSigner.sign(template)
|
|
||||||
|
|
||||||
database.nostrEventDao().upsert(
|
|
||||||
NostrEvent(
|
|
||||||
id = commitEvent.id,
|
|
||||||
createdAt = Instant.fromEpochSeconds(commitEvent.createdAt),
|
|
||||||
content = commitEvent.content,
|
|
||||||
sig = commitEvent.sig,
|
|
||||||
tags = commitEvent.tags,
|
|
||||||
kind = commitEvent.kind,
|
|
||||||
pubKey = commitEvent.pubKey
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Save commitResult... in case we need to broadcast welcomeEvent after relay acknowledgement...
|
|
||||||
database.marmotCommitResultDao().upsert(
|
|
||||||
MarmotCommitResult(
|
|
||||||
id = commitEvent.id,
|
|
||||||
isOneMemberInitialGroupCreation = isOneMemberInitialGroupCreation,
|
|
||||||
chatRoomId = nostrGroupId,
|
|
||||||
commitBytes = commitResult.commitBytes,
|
|
||||||
preCommitExporterSecret = commitResult.preCommitExporterSecret,
|
|
||||||
welcomeBytes = commitResult.welcomeBytes,
|
|
||||||
framedCommitBytes = commitResult.preCommitExporterSecret,
|
|
||||||
groupInfoBytes = commitResult.groupInfoBytes,
|
|
||||||
userPublicKey = userPublicKey,
|
|
||||||
peerKeyPackageEventId = peerKeyPackage.id,
|
|
||||||
createdAt = Instant.fromEpochSeconds(commitEvent.createdAt)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
database.broadcastNostrEventRequestDao().insert(
|
|
||||||
relays.map {
|
|
||||||
BroadcastNostrEventRequest(
|
|
||||||
nostrEventId = commitEvent.id,
|
|
||||||
relayURL = it
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (isOneMemberInitialGroupCreation) {
|
if (isOneMemberInitialGroupCreation) {
|
||||||
// Send welcome event to participant
|
// Send welcome event to participant
|
||||||
commitResult.welcomeBytes?.let { welcomeBytes ->
|
commitResult.welcomeBytes?.let { welcomeBytes ->
|
||||||
@@ -235,6 +182,60 @@ abstract class MarmotOutboundDao(
|
|||||||
relays = relays,
|
relays = relays,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// CommitEvent...
|
||||||
|
val encryptedContent = encryptedCommitEvent(
|
||||||
|
mlsGroup,
|
||||||
|
commitBytes = commitResult.framedCommitBytes,
|
||||||
|
exporterKey = commitResult.preCommitExporterSecret
|
||||||
|
)
|
||||||
|
|
||||||
|
val template = GroupEvent.build(
|
||||||
|
encryptedContentBase64 = encryptedContent,
|
||||||
|
nostrGroupId = nostrGroupId
|
||||||
|
)
|
||||||
|
|
||||||
|
val ephemeralSigner = NostrSignerInternal(KeyPair())
|
||||||
|
val commitEvent: GroupEvent = ephemeralSigner.sign(template)
|
||||||
|
|
||||||
|
database.nostrEventDao().upsert(
|
||||||
|
NostrEvent(
|
||||||
|
id = commitEvent.id,
|
||||||
|
createdAt = Instant.fromEpochSeconds(commitEvent.createdAt),
|
||||||
|
content = commitEvent.content,
|
||||||
|
sig = commitEvent.sig,
|
||||||
|
tags = commitEvent.tags,
|
||||||
|
kind = commitEvent.kind,
|
||||||
|
pubKey = commitEvent.pubKey
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Save commitResult... in case we need to broadcast welcomeEvent after relay acknowledgement...
|
||||||
|
database.marmotCommitResultDao().upsert(
|
||||||
|
MarmotCommitResult(
|
||||||
|
id = commitEvent.id,
|
||||||
|
isOneMemberInitialGroupCreation = isOneMemberInitialGroupCreation,
|
||||||
|
chatRoomId = nostrGroupId,
|
||||||
|
commitBytes = commitResult.commitBytes,
|
||||||
|
preCommitExporterSecret = commitResult.preCommitExporterSecret,
|
||||||
|
welcomeBytes = commitResult.welcomeBytes,
|
||||||
|
framedCommitBytes = commitResult.preCommitExporterSecret,
|
||||||
|
groupInfoBytes = commitResult.groupInfoBytes,
|
||||||
|
userPublicKey = userPublicKey,
|
||||||
|
peerKeyPackageEventId = peerKeyPackage.id,
|
||||||
|
createdAt = Instant.fromEpochSeconds(commitEvent.createdAt)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Broadcast commitment so other members get it...
|
||||||
|
database.broadcastNostrEventRequestDao().insert(
|
||||||
|
relays.map {
|
||||||
|
BroadcastNostrEventRequest(
|
||||||
|
nostrEventId = commitEvent.id,
|
||||||
|
relayURL = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user