ExpirationTimerUpdate refactor

This commit is contained in:
charles 2022-11-22 12:08:58 +11:00
parent 962e648bb8
commit fa1a2f5a9d
11 changed files with 14 additions and 13 deletions

View file

@ -39,7 +39,7 @@ abstract class Message {
dataMessage.group = groupProto.build()
}
fun setExpirationSettingsConfigIfNeeded(builder: SignalServiceProtos.Content.Builder) {
fun setExpirationConfigurationIfNeeded(builder: SignalServiceProtos.Content.Builder) {
val threadId = threadID ?: return
val config = MessagingModuleConfiguration.shared.storage.getExpirationConfiguration(threadId) ?: return
builder.expirationTimer = config.durationSeconds

View file

@ -82,7 +82,7 @@ class CallMessage(): ControlMessage() {
.setUuid(callId!!.toString())
val content = SignalServiceProtos.Content.newBuilder()
setExpirationSettingsConfigIfNeeded(content)
setExpirationConfigurationIfNeeded(content)
return content
.setCallMessage(callMessage)

View file

@ -168,7 +168,7 @@ class ClosedGroupControlMessage() : ControlMessage() {
val dataMessageProto = DataMessage.newBuilder()
dataMessageProto.closedGroupControlMessage = closedGroupControlMessage.build()
// Expiration timer
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
// Group context
setGroupContext(dataMessageProto)
contentProto.dataMessage = dataMessageProto.build()

View file

@ -64,7 +64,7 @@ class DataExtractionNotification() : ControlMessage() {
}
val contentProto = SignalServiceProtos.Content.newBuilder()
contentProto.dataExtractionNotification = dataExtractionNotification.build()
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
return contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct data extraction notification proto from: $this")

View file

@ -66,12 +66,13 @@ class ExpirationTimerUpdate() : ControlMessage() {
}
}
val contentProto = SignalServiceProtos.Content.newBuilder()
try {
return try {
contentProto.dataMessage = dataMessageProto.build()
return contentProto.build()
setExpirationConfigurationIfNeeded(contentProto)
contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct expiration timer update proto from: $this")
return null
null
}
}
}

View file

@ -13,7 +13,7 @@ class MessageRequestResponse(val isApproved: Boolean) : ControlMessage() {
val contentProto = SignalServiceProtos.Content.newBuilder()
return try {
contentProto.messageRequestResponse = messageRequestResponseProto.build()
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct message request response proto from: $this")

View file

@ -41,7 +41,7 @@ class ReadReceipt() : ControlMessage() {
val contentProto = SignalServiceProtos.Content.newBuilder()
return try {
contentProto.receiptMessage = receiptProto.build()
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct read receipt proto from: $this")

View file

@ -50,7 +50,7 @@ class SyncedExpiriesMessage(): ControlMessage() {
val contentProto = SignalServiceProtos.Content.newBuilder()
return try {
contentProto.syncedExpiries = syncedExpiriesProto.build()
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct synced expiries proto from: $this")

View file

@ -60,7 +60,7 @@ class TypingIndicator() : ControlMessage() {
val contentProto = SignalServiceProtos.Content.newBuilder()
return try {
contentProto.typingMessage = typingIndicatorProto.build()
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct typing indicator proto from: $this")

View file

@ -45,7 +45,7 @@ class UnsendRequest(): ControlMessage() {
val contentProto = SignalServiceProtos.Content.newBuilder()
return try {
contentProto.unsendRequest = unsendRequestProto.build()
setExpirationSettingsConfigIfNeeded(contentProto)
setExpirationConfigurationIfNeeded(contentProto)
contentProto.build()
} catch (e: Exception) {
Log.w(TAG, "Couldn't construct unsend request proto from: $this")

View file

@ -116,7 +116,7 @@ class VisibleMessage : Message() {
dataMessage.addAllAttachments(pointers)
// TODO: Contact
// Expiration timer
setExpirationSettingsConfigIfNeeded(proto)
setExpirationConfigurationIfNeeded(proto)
// Group context
val storage = MessagingModuleConfiguration.shared.storage
if (storage.isClosedGroup(recipient!!)) {