mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
adding openGroupInvitation types in proto & class
This commit is contained in:
parent
43c484e35f
commit
99a62d9e99
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -40,7 +40,8 @@ message Content {
|
||||
optional ReceiptMessage receiptMessage = 5;
|
||||
optional TypingMessage typingMessage = 6;
|
||||
optional ConfigurationMessage configurationMessage = 7;
|
||||
optional DataExtractionNotification dataExtractionNotification = 82;
|
||||
optional DataExtractionNotification dataExtractionNotification = 8;
|
||||
optional OpenGroupInvitation openGroupInvitation = 9;
|
||||
}
|
||||
|
||||
message KeyPair {
|
||||
@ -144,6 +145,12 @@ message DataMessage {
|
||||
optional string syncTarget = 105;
|
||||
}
|
||||
|
||||
message OpenGroupInvitation {
|
||||
optional string serverAddress = 1;
|
||||
optional uint32 channelId = 2;
|
||||
optional string serverName = 3;
|
||||
}
|
||||
|
||||
message ConfigurationMessage {
|
||||
|
||||
message ClosedGroup {
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user