mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-02 14:35:21 +00:00
ReadReceipt implementation + small corrections
This commit is contained in:
parent
8f409faefc
commit
746df2240a
@ -1,17 +1,53 @@
|
|||||||
package org.session.libsession.messaging.messages.control
|
package org.session.libsession.messaging.messages.control
|
||||||
|
|
||||||
|
import org.session.libsignal.libsignal.logging.Log
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||||
|
|
||||||
class ReadReceipt() : ControlMessage() {
|
class ReadReceipt() : ControlMessage() {
|
||||||
|
|
||||||
|
var timestamps: LongArray? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
const val TAG = "ReadReceipt"
|
||||||
TODO("Not yet implemented")
|
|
||||||
|
fun fromProto(proto: SignalServiceProtos.Content): ReadReceipt? {
|
||||||
|
val receiptProto = proto.receiptMessage ?: return null
|
||||||
|
if (receiptProto.type != SignalServiceProtos.ReceiptMessage.Type.READ) return null
|
||||||
|
val timestamps = receiptProto.timestampList
|
||||||
|
if (timestamps.isEmpty()) return null
|
||||||
|
return ReadReceipt(timestamps = timestamps.toLongArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//constructor
|
||||||
|
internal constructor(timestamps: LongArray?) : this() {
|
||||||
|
this.timestamps = timestamps
|
||||||
|
}
|
||||||
|
|
||||||
|
// validation
|
||||||
|
override fun isValid(): Boolean {
|
||||||
|
if (!super.isValid()) return false
|
||||||
|
val timestamps = timestamps ?: return false
|
||||||
|
if (timestamps.isNotEmpty()) { return true }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun toProto(): SignalServiceProtos.Content? {
|
override fun toProto(): SignalServiceProtos.Content? {
|
||||||
TODO("Not yet implemented")
|
val timestamps = timestamps ?: return null
|
||||||
|
if (timestamps == null) {
|
||||||
|
Log.w(ExpirationTimerUpdate.TAG, "Couldn't construct read receipt proto from: $this")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val receiptProto = SignalServiceProtos.ReceiptMessage.newBuilder()
|
||||||
|
receiptProto.type = SignalServiceProtos.ReceiptMessage.Type.READ
|
||||||
|
receiptProto.addAllTimestamp(timestamps.asIterable())
|
||||||
|
val contentProto = SignalServiceProtos.Content.newBuilder()
|
||||||
|
try {
|
||||||
|
contentProto.receiptMessage = receiptProto.build()
|
||||||
|
return contentProto.build()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.w(ExpirationTimerUpdate.TAG, "Couldn't construct read receipt proto from: $this")
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
class TypingIndicator : ControlMessage() {
|
class TypingIndicator : ControlMessage() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): TypingIndicator? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ class NullMessage() : ControlMessage() {
|
|||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): NullMessage? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
class SessionRequest() : ControlMessage() {
|
class SessionRequest() : ControlMessage() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): SessionRequest? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
internal class Contact : VisibleMessage() {
|
internal class Contact : VisibleMessage() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): Contact? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
internal class LinkPreview : VisibleMessage(){
|
internal class LinkPreview : VisibleMessage(){
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): LinkPreview? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
internal class Profile : VisibleMessage() {
|
internal class Profile : VisibleMessage() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): Profile? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
internal class Quote : VisibleMessage() {
|
internal class Quote : VisibleMessage() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): Quote? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|||||||
internal class Attachment : VisibleMessage() {
|
internal class Attachment : VisibleMessage() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromProto(proto: SignalServiceProtos.Content): ExpirationTimerUpdate? {
|
fun fromProto(proto: SignalServiceProtos.Content): Attachment? {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user