adding openGroupInvitation types in proto & class

This commit is contained in:
Brice-W 2021-04-30 16:00:13 +10:00
parent 43c484e35f
commit 99a62d9e99
3 changed files with 1073 additions and 100 deletions

View File

@ -0,0 +1,51 @@
package org.session.libsession.messaging.messages.control
import org.session.libsignal.service.internal.push.SignalServiceProtos
import org.session.libsignal.utilities.logging.Log
class OpenGroupInvitation() : ControlMessage() {
var serverAddress: String? = null;
var channelId: Int? = 0;
var serverName: String? = null;
companion object {
const val TAG = "OpenGroupInvitation"
fun fromProto(proto: SignalServiceProtos.Content): OpenGroupInvitation? {
val openGroupInvitationProto = if (proto.hasOpenGroupInvitation()) proto.openGroupInvitation else return null
val serverAddress = openGroupInvitationProto.serverAddress
val channelId = openGroupInvitationProto.channelId
val serverName = openGroupInvitationProto.serverName
return OpenGroupInvitation(serverAddress, channelId, serverName)
}
}
constructor(serverAddress: String?, channelId: Int, serverName: String?): this() {
this.serverAddress = serverAddress
this.channelId = channelId
this.serverName = serverName
}
override fun isValid(): Boolean {
if (!super.isValid()) return false
//TODO determine what's required
return (serverAddress != null && channelId != null && serverName != null)
}
override fun toProto(): SignalServiceProtos.Content? {
val openGroupInvitationProto = SignalServiceProtos.OpenGroupInvitation.newBuilder()
openGroupInvitationProto.serverAddress = serverAddress
openGroupInvitationProto.channelId = channelId ?: 0
openGroupInvitationProto.serverName = serverName
val proto = SignalServiceProtos.Content.newBuilder()
return try {
proto.openGroupInvitation = openGroupInvitationProto.build()
proto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct open group invitation proto from: $this")
null
}
}
}

View File

@ -40,7 +40,8 @@ message Content {
optional ReceiptMessage receiptMessage = 5; optional ReceiptMessage receiptMessage = 5;
optional TypingMessage typingMessage = 6; optional TypingMessage typingMessage = 6;
optional ConfigurationMessage configurationMessage = 7; optional ConfigurationMessage configurationMessage = 7;
optional DataExtractionNotification dataExtractionNotification = 82; optional DataExtractionNotification dataExtractionNotification = 8;
optional OpenGroupInvitation openGroupInvitation = 9;
} }
message KeyPair { message KeyPair {
@ -144,6 +145,12 @@ message DataMessage {
optional string syncTarget = 105; optional string syncTarget = 105;
} }
message OpenGroupInvitation {
optional string serverAddress = 1;
optional uint32 channelId = 2;
optional string serverName = 3;
}
message ConfigurationMessage { message ConfigurationMessage {
message ClosedGroup { message ClosedGroup {