mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 12:48:26 +00:00
NullMessage implementation
This commit is contained in:
parent
3a0ba29a72
commit
2c167b0cc0
@ -1,19 +1,37 @@
|
||||
package org.session.libsession.messaging.messages.control.unused
|
||||
|
||||
import com.google.protobuf.ByteString
|
||||
import org.session.libsession.messaging.messages.control.ControlMessage
|
||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||
import org.session.libsession.messaging.messages.control.TypingIndicator
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
import java.security.SecureRandom
|
||||
|
||||
class NullMessage() : ControlMessage() {
|
||||
|
||||
|
||||
companion object {
|
||||
const val TAG = "NullMessage"
|
||||
|
||||
fun fromProto(proto: SignalServiceProtos.Content): NullMessage? {
|
||||
TODO("Not yet implemented")
|
||||
if (proto.nullMessage == null) return null
|
||||
return NullMessage()
|
||||
}
|
||||
}
|
||||
|
||||
override fun toProto(): SignalServiceProtos.Content? {
|
||||
TODO("Not yet implemented")
|
||||
val nullMessageProto = SignalServiceProtos.NullMessage.newBuilder()
|
||||
val sr = SecureRandom()
|
||||
val paddingSize = sr.nextInt(512)
|
||||
val padding = ByteArray(paddingSize)
|
||||
nullMessageProto.padding = ByteString.copyFrom(padding)
|
||||
val contentProto = SignalServiceProtos.Content.newBuilder()
|
||||
try {
|
||||
contentProto.nullMessage = nullMessageProto.build()
|
||||
return contentProto.build()
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Couldn't construct null message proto from: $this")
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user