mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 14:47:44 +00:00
Add follow setting button
This commit is contained in:
@@ -56,8 +56,6 @@ data class ExpirationTimerUpdate(var expiryMode: ExpiryMode, var syncTarget: Str
|
||||
}
|
||||
return try {
|
||||
SignalServiceProtos.Content.newBuilder().apply {
|
||||
expirationType
|
||||
expirationTimer
|
||||
dataMessage = dataMessageProto.build()
|
||||
setExpirationConfigurationIfNeeded(threadID)
|
||||
}.build()
|
||||
|
@@ -151,11 +151,10 @@ object MessageReceiver {
|
||||
|
||||
val isUserBlindedSender = sender == openGroupPublicKey?.let { SodiumUtilities.blindedKeyPair(it, MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!) }?.let { SessionId(IdPrefix.BLINDED, it.publicKey.asBytes).hexString }
|
||||
val isUserSender = sender == userPublicKey
|
||||
// Ignore self send if needed
|
||||
if (!message.isSelfSendValid && (isUserSender || isUserBlindedSender)) {
|
||||
throw Error.SelfSend
|
||||
}
|
||||
|
||||
if (isUserSender || isUserBlindedSender) {
|
||||
// Ignore self send if needed
|
||||
if (!message.isSelfSendValid) throw Error.SelfSend
|
||||
message.isSenderSelf = true
|
||||
}
|
||||
// Guard against control messages in open groups
|
||||
|
@@ -12,14 +12,14 @@ import org.session.libsession.messaging.calls.CallMessageType.CALL_OUTGOING
|
||||
import org.session.libsession.messaging.contacts.Contact
|
||||
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
||||
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
||||
import org.session.libsession.utilities.Address
|
||||
import org.session.libsession.utilities.ExpirationUtil
|
||||
import org.session.libsession.utilities.getExpirationTypeDisplayValue
|
||||
import org.session.libsession.utilities.truncateIdForDisplay
|
||||
|
||||
object UpdateMessageBuilder {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
|
||||
fun getSenderName(senderId: String) = storage.getContactWithSessionID(senderId)
|
||||
private fun getSenderName(senderId: String) = storage.getContactWithSessionID(senderId)
|
||||
?.displayName(Contact.ContactContext.REGULAR)
|
||||
?: truncateIdForDisplay(senderId)
|
||||
|
||||
@@ -76,11 +76,17 @@ object UpdateMessageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
fun buildExpirationTimerMessage(context: Context, duration: Long, senderId: String? = null, threadId: Long, isOutgoing: Boolean = false): String {
|
||||
fun buildExpirationTimerMessage(
|
||||
context: Context,
|
||||
duration: Long,
|
||||
senderId: String? = null,
|
||||
threadId: Long,
|
||||
isOutgoing: Boolean = false,
|
||||
timestamp: Long,
|
||||
expireStarted: Long
|
||||
): String {
|
||||
if (!isOutgoing && senderId == null) return ""
|
||||
val senderName: String = if (!isOutgoing) {
|
||||
getSenderName(senderId!!)
|
||||
} else { context.getString(R.string.MessageRecord_you) }
|
||||
val senderName = if (isOutgoing) context.getString(R.string.MessageRecord_you) else getSenderName(senderId!!)
|
||||
return if (duration <= 0) {
|
||||
if (isOutgoing) {
|
||||
if (ExpirationConfiguration.isNewConfigEnabled) {
|
||||
@@ -98,11 +104,7 @@ object UpdateMessageBuilder {
|
||||
} else {
|
||||
val time = ExpirationUtil.getExpirationDisplayValue(context, duration.toInt())
|
||||
val config = threadId.let { storage.getExpirationConfiguration(it) }
|
||||
val state = when (config?.expiryMode) {
|
||||
is ExpiryMode.AfterSend -> context.getString(R.string.MessageRecord_state_sent)
|
||||
is ExpiryMode.AfterRead -> context.getString(R.string.MessageRecord_state_read)
|
||||
else -> ""
|
||||
}
|
||||
val state = context.getExpirationTypeDisplayValue(timestamp == expireStarted)
|
||||
if (isOutgoing) {
|
||||
if (ExpirationConfiguration.isNewConfigEnabled) {
|
||||
context.getString(R.string.MessageRecord_you_set_messages_to_disappear_s_after_s, time, state)
|
||||
|
@@ -1,10 +1,13 @@
|
||||
package org.session.libsession.utilities
|
||||
|
||||
import android.content.Context
|
||||
import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||
import org.session.libsession.R
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.time.Duration
|
||||
|
||||
fun Context.getExpirationTypeDisplayValue(sent: Boolean) = if (sent) getString(R.string.MessageRecord_state_sent) else getString(R.string.MessageRecord_state_read)
|
||||
|
||||
object ExpirationUtil {
|
||||
@JvmStatic
|
||||
fun getExpirationDisplayValue(context: Context, duration: Duration): String = getExpirationDisplayValue(context, duration.inWholeSeconds.toInt())
|
||||
|
Reference in New Issue
Block a user