few little fixes

This commit is contained in:
Brice-W 2021-03-23 10:11:10 +11:00
parent c0e7f05d91
commit e378d11692
3 changed files with 8 additions and 11 deletions

View File

@ -38,7 +38,7 @@ class ClosedGroupControlMessage() : ControlMessage() {
object MemberLeft : Kind()
object EncryptionKeyPairRequest: Kind()
val description: String = run {
val description: String =
when(this) {
is New -> "new"
is Update -> "update"
@ -49,7 +49,6 @@ class ClosedGroupControlMessage() : ControlMessage() {
MemberLeft -> "memberLeft"
EncryptionKeyPairRequest -> "encryptionKeyPairRequest"
}
}
}
companion object {

View File

@ -14,12 +14,11 @@ class DataExtractionNotification(): ControlMessage() {
class Screenshot() : Kind()
class MediaSaved(val timestanp: Long) : Kind()
val description: String = run {
val description: String =
when(this) {
is Screenshot -> "screenshot"
is MediaSaved -> "mediaSaved"
}
}
}
companion object {
@ -27,12 +26,11 @@ class DataExtractionNotification(): ControlMessage() {
fun fromProto(proto: SignalServiceProtos.Content): DataExtractionNotification? {
val dataExtractionNotification = proto.dataExtractionNotification ?: return null
val kind: Kind
when(dataExtractionNotification.type) {
SignalServiceProtos.DataExtractionNotification.Type.SCREENSHOT -> kind = Kind.Screenshot()
val kind: Kind = when(dataExtractionNotification.type) {
SignalServiceProtos.DataExtractionNotification.Type.SCREENSHOT -> Kind.Screenshot()
SignalServiceProtos.DataExtractionNotification.Type.MEDIA_SAVED -> {
val timestamp = if (dataExtractionNotification.hasTimestamp()) dataExtractionNotification.timestamp else 0
kind = Kind.MediaSaved(timestamp)
val timestamp = if (dataExtractionNotification.hasTimestamp()) dataExtractionNotification.timestamp else return null
Kind.MediaSaved(timestamp)
}
}
return DataExtractionNotification(kind)

View File

@ -35,7 +35,7 @@ class ReadReceipt() : ControlMessage() {
override fun toProto(): SignalServiceProtos.Content? {
val timestamps = timestamps
if (timestamps == null) {
Log.w(ExpirationTimerUpdate.TAG, "Couldn't construct read receipt proto from: $this")
Log.w(TAG, "Couldn't construct read receipt proto from: $this")
return null
}
val receiptProto = SignalServiceProtos.ReceiptMessage.newBuilder()
@ -46,7 +46,7 @@ class ReadReceipt() : ControlMessage() {
contentProto.receiptMessage = receiptProto.build()
return contentProto.build()
} catch (e: Exception) {
Log.w(ExpirationTimerUpdate.TAG, "Couldn't construct read receipt proto from: $this")
Log.w(TAG, "Couldn't construct read receipt proto from: $this")
return null
}
}