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 MemberLeft : Kind()
object EncryptionKeyPairRequest: Kind() object EncryptionKeyPairRequest: Kind()
val description: String = run { val description: String =
when(this) { when(this) {
is New -> "new" is New -> "new"
is Update -> "update" is Update -> "update"
@ -50,7 +50,6 @@ class ClosedGroupControlMessage() : ControlMessage() {
EncryptionKeyPairRequest -> "encryptionKeyPairRequest" EncryptionKeyPairRequest -> "encryptionKeyPairRequest"
} }
} }
}
companion object { companion object {
const val TAG = "ClosedGroupControlMessage" const val TAG = "ClosedGroupControlMessage"

View File

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

View File

@ -35,7 +35,7 @@ class ReadReceipt() : ControlMessage() {
override fun toProto(): SignalServiceProtos.Content? { override fun toProto(): SignalServiceProtos.Content? {
val timestamps = timestamps val timestamps = timestamps
if (timestamps == null) { 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 return null
} }
val receiptProto = SignalServiceProtos.ReceiptMessage.newBuilder() val receiptProto = SignalServiceProtos.ReceiptMessage.newBuilder()
@ -46,7 +46,7 @@ class ReadReceipt() : ControlMessage() {
contentProto.receiptMessage = receiptProto.build() contentProto.receiptMessage = receiptProto.build()
return contentProto.build() return contentProto.build()
} catch (e: Exception) { } 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 return null
} }
} }