mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
ExpirationTimerUpdate refactor
This commit is contained in:
parent
962e648bb8
commit
fa1a2f5a9d
@ -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
|
||||
|
@ -82,7 +82,7 @@ class CallMessage(): ControlMessage() {
|
||||
.setUuid(callId!!.toString())
|
||||
|
||||
val content = SignalServiceProtos.Content.newBuilder()
|
||||
setExpirationSettingsConfigIfNeeded(content)
|
||||
setExpirationConfigurationIfNeeded(content)
|
||||
|
||||
return content
|
||||
.setCallMessage(callMessage)
|
||||
|
@ -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()
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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!!)) {
|
||||
|
Loading…
Reference in New Issue
Block a user