mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
add unsend request proto
This commit is contained in:
parent
18c177971a
commit
c0a5a61431
@ -0,0 +1,55 @@
|
|||||||
|
package org.session.libsession.messaging.messages.control
|
||||||
|
|
||||||
|
import org.session.libsignal.protos.SignalServiceProtos
|
||||||
|
import org.session.libsignal.utilities.Log
|
||||||
|
|
||||||
|
class UnsendRequest(): ControlMessage() {
|
||||||
|
var timestamp: Long? = null
|
||||||
|
var author: String? = null
|
||||||
|
|
||||||
|
override val isSelfSendValid: Boolean = true
|
||||||
|
|
||||||
|
// region Validation
|
||||||
|
override fun isValid(): Boolean {
|
||||||
|
if (!super.isValid()) return false
|
||||||
|
return timestamp != null && author != null
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val TAG = "UnsendRequest"
|
||||||
|
|
||||||
|
fun fromProto(proto: SignalServiceProtos.Content): UnsendRequest? {
|
||||||
|
val unsendRequestProto = if (proto.hasUnsendRequest()) proto.unsendRequest else return null
|
||||||
|
val timestamp = unsendRequestProto.timestamp
|
||||||
|
val author = unsendRequestProto.author
|
||||||
|
return UnsendRequest(timestamp, author)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(timestamp: Long, author: String) : this() {
|
||||||
|
this.timestamp = timestamp
|
||||||
|
this.author = author
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toProto(): SignalServiceProtos.Content? {
|
||||||
|
val timestamp = timestamp
|
||||||
|
val author = author
|
||||||
|
if (timestamp == null || author == null) {
|
||||||
|
Log.w(TAG, "Couldn't construct unsend request proto from: $this")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val unsendRequestProto = SignalServiceProtos.UnsendRequest.newBuilder()
|
||||||
|
unsendRequestProto.timestamp = timestamp
|
||||||
|
unsendRequestProto.author = author
|
||||||
|
val contentProto = SignalServiceProtos.Content.newBuilder()
|
||||||
|
try {
|
||||||
|
contentProto.unsendRequest = unsendRequestProto.build()
|
||||||
|
return contentProto.build()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.w(TAG, "Couldn't construct unsend request proto from: $this")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -35,12 +35,20 @@ message TypingMessage {
|
|||||||
required Action action = 2;
|
required Action action = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UnsendRequest {
|
||||||
|
// @required
|
||||||
|
required uint64 timestamp = 1;
|
||||||
|
// @required
|
||||||
|
required string author = 2;
|
||||||
|
}
|
||||||
|
|
||||||
message Content {
|
message Content {
|
||||||
optional DataMessage dataMessage = 1;
|
optional DataMessage dataMessage = 1;
|
||||||
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 = 8;
|
optional DataExtractionNotification dataExtractionNotification = 8;
|
||||||
|
optional UnsendRequest unsendRequest = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message KeyPair {
|
message KeyPair {
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user