mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
fix closed group updating
This commit is contained in:
parent
88ac390495
commit
a1d1b864e6
@ -35,8 +35,8 @@ class ClosedGroupControlMessage() : ControlMessage() {
|
|||||||
class NameChange(val name: String) : Kind()
|
class NameChange(val name: String) : Kind()
|
||||||
class MembersAdded(val members: List<ByteString>) : Kind()
|
class MembersAdded(val members: List<ByteString>) : Kind()
|
||||||
class MembersRemoved( val members: List<ByteString>) : Kind()
|
class MembersRemoved( val members: List<ByteString>) : Kind()
|
||||||
object MemberLeft : Kind()
|
class MemberLeft : Kind()
|
||||||
object EncryptionKeyPairRequest: Kind()
|
class EncryptionKeyPairRequest: Kind()
|
||||||
|
|
||||||
val description: String = run {
|
val description: String = run {
|
||||||
when(this) {
|
when(this) {
|
||||||
@ -46,8 +46,8 @@ class ClosedGroupControlMessage() : ControlMessage() {
|
|||||||
is NameChange -> "nameChange"
|
is NameChange -> "nameChange"
|
||||||
is MembersAdded -> "membersAdded"
|
is MembersAdded -> "membersAdded"
|
||||||
is MembersRemoved -> "membersRemoved"
|
is MembersRemoved -> "membersRemoved"
|
||||||
MemberLeft -> "memberLeft"
|
is MemberLeft -> "memberLeft"
|
||||||
EncryptionKeyPairRequest -> "encryptionKeyPairRequest"
|
is EncryptionKeyPairRequest -> "encryptionKeyPairRequest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,10 +92,10 @@ class ClosedGroupControlMessage() : ControlMessage() {
|
|||||||
kind = Kind.MembersRemoved(closedGroupControlMessageProto.membersList)
|
kind = Kind.MembersRemoved(closedGroupControlMessageProto.membersList)
|
||||||
}
|
}
|
||||||
DataMessage.ClosedGroupControlMessage.Type.MEMBER_LEFT -> {
|
DataMessage.ClosedGroupControlMessage.Type.MEMBER_LEFT -> {
|
||||||
kind = Kind.MemberLeft
|
kind = Kind.MemberLeft()
|
||||||
}
|
}
|
||||||
DataMessage.ClosedGroupControlMessage.Type.ENCRYPTION_KEY_PAIR_REQUEST -> {
|
DataMessage.ClosedGroupControlMessage.Type.ENCRYPTION_KEY_PAIR_REQUEST -> {
|
||||||
kind = Kind.EncryptionKeyPairRequest
|
kind = Kind.EncryptionKeyPairRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ClosedGroupControlMessage(kind)
|
return ClosedGroupControlMessage(kind)
|
||||||
|
@ -212,8 +212,8 @@ private fun MessageReceiver.handleClosedGroupControlMessage(message: ClosedGroup
|
|||||||
is ClosedGroupControlMessage.Kind.NameChange -> handleClosedGroupNameChanged(message)
|
is ClosedGroupControlMessage.Kind.NameChange -> handleClosedGroupNameChanged(message)
|
||||||
is ClosedGroupControlMessage.Kind.MembersAdded -> handleClosedGroupMembersAdded(message)
|
is ClosedGroupControlMessage.Kind.MembersAdded -> handleClosedGroupMembersAdded(message)
|
||||||
is ClosedGroupControlMessage.Kind.MembersRemoved -> handleClosedGroupMembersRemoved(message)
|
is ClosedGroupControlMessage.Kind.MembersRemoved -> handleClosedGroupMembersRemoved(message)
|
||||||
ClosedGroupControlMessage.Kind.MemberLeft -> handleClosedGroupMemberLeft(message)
|
is ClosedGroupControlMessage.Kind.MemberLeft -> handleClosedGroupMemberLeft(message)
|
||||||
ClosedGroupControlMessage.Kind.EncryptionKeyPairRequest -> handleClosedGroupEncryptionKeyPairRequest(message)
|
is ClosedGroupControlMessage.Kind.EncryptionKeyPairRequest -> handleClosedGroupEncryptionKeyPairRequest(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +50,11 @@ fun MessageSender.create(name: String, members: Collection<String>): Promise<Str
|
|||||||
storage.setProfileSharing(Address.fromSerialized(groupID), true)
|
storage.setProfileSharing(Address.fromSerialized(groupID), true)
|
||||||
// Send a closed group update message to all members individually
|
// Send a closed group update message to all members individually
|
||||||
val closedGroupUpdateKind = ClosedGroupControlMessage.Kind.New(ByteString.copyFrom(Hex.fromStringCondensed(groupPublicKey)), name, encryptionKeyPair, membersAsData, adminsAsData)
|
val closedGroupUpdateKind = ClosedGroupControlMessage.Kind.New(ByteString.copyFrom(Hex.fromStringCondensed(groupPublicKey)), name, encryptionKeyPair, membersAsData, adminsAsData)
|
||||||
|
val sentTime = System.currentTimeMillis()
|
||||||
for (member in members) {
|
for (member in members) {
|
||||||
val closedGroupControlMessage = ClosedGroupControlMessage(closedGroupUpdateKind)
|
val closedGroupControlMessage = ClosedGroupControlMessage(closedGroupUpdateKind)
|
||||||
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID)).get()
|
closedGroupControlMessage.sentTimestamp = sentTime
|
||||||
|
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(member)).get()
|
||||||
}
|
}
|
||||||
// Add the group to the user's set of public keys to poll for
|
// Add the group to the user's set of public keys to poll for
|
||||||
storage.addClosedGroupPublicKey(groupPublicKey)
|
storage.addClosedGroupPublicKey(groupPublicKey)
|
||||||
@ -199,7 +201,7 @@ fun MessageSender.leave(groupPublicKey: String, notifyUser: Boolean = true): Pro
|
|||||||
val admins = group.admins.map { it.serialize() }
|
val admins = group.admins.map { it.serialize() }
|
||||||
val name = group.title
|
val name = group.title
|
||||||
// Send the update to the group
|
// Send the update to the group
|
||||||
val closedGroupControlMessage = ClosedGroupControlMessage(ClosedGroupControlMessage.Kind.MemberLeft)
|
val closedGroupControlMessage = ClosedGroupControlMessage(ClosedGroupControlMessage.Kind.MemberLeft())
|
||||||
closedGroupControlMessage.sentTimestamp = System.currentTimeMillis()
|
closedGroupControlMessage.sentTimestamp = System.currentTimeMillis()
|
||||||
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID)).success {
|
sendNonDurably(closedGroupControlMessage, Address.fromSerialized(groupID)).success {
|
||||||
// Notify the user
|
// Notify the user
|
||||||
@ -265,7 +267,7 @@ fun MessageSender.requestEncryptionKeyPair(groupPublicKey: String) {
|
|||||||
val members = group.members.map { it.serialize() }.toSet()
|
val members = group.members.map { it.serialize() }.toSet()
|
||||||
if (!members.contains(storage.getUserPublicKey()!!)) return
|
if (!members.contains(storage.getUserPublicKey()!!)) return
|
||||||
// Send the request to the group
|
// Send the request to the group
|
||||||
val closedGroupControlMessage = ClosedGroupControlMessage(ClosedGroupControlMessage.Kind.EncryptionKeyPairRequest)
|
val closedGroupControlMessage = ClosedGroupControlMessage(ClosedGroupControlMessage.Kind.EncryptionKeyPairRequest())
|
||||||
send(closedGroupControlMessage, Address.fromSerialized(groupID))
|
send(closedGroupControlMessage, Address.fromSerialized(groupID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user