|
|
|
@ -7,16 +7,17 @@ import org.session.libsession.messaging.calls.CallMessageType
|
|
|
|
|
import org.session.libsession.messaging.contacts.Contact
|
|
|
|
|
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
|
|
|
|
import org.session.libsession.utilities.ExpirationUtil
|
|
|
|
|
import org.session.libsession.utilities.truncateIdForDisplay
|
|
|
|
|
|
|
|
|
|
object UpdateMessageBuilder {
|
|
|
|
|
|
|
|
|
|
fun buildGroupUpdateMessage(context: Context, updateMessageData: UpdateMessageData, sender: String? = null, isOutgoing: Boolean = false): String {
|
|
|
|
|
fun buildGroupUpdateMessage(context: Context, updateMessageData: UpdateMessageData, senderId: String? = null, isOutgoing: Boolean = false): String {
|
|
|
|
|
var message = ""
|
|
|
|
|
val updateData = updateMessageData.kind ?: return message
|
|
|
|
|
if (!isOutgoing && sender == null) return message
|
|
|
|
|
if (!isOutgoing && senderId == null) return message
|
|
|
|
|
val storage = MessagingModuleConfiguration.shared.storage
|
|
|
|
|
val senderName: String = if (!isOutgoing) {
|
|
|
|
|
storage.getContactWithSessionID(sender!!)?.displayName(Contact.ContactContext.REGULAR) ?: sender
|
|
|
|
|
storage.getContactWithSessionID(senderId!!)?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId)
|
|
|
|
|
} else { context.getString(R.string.MessageRecord_you) }
|
|
|
|
|
|
|
|
|
|
when (updateData) {
|
|
|
|
@ -77,11 +78,11 @@ object UpdateMessageBuilder {
|
|
|
|
|
return message
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun buildExpirationTimerMessage(context: Context, duration: Long, sender: String? = null, isOutgoing: Boolean = false): String {
|
|
|
|
|
if (!isOutgoing && sender == null) return ""
|
|
|
|
|
fun buildExpirationTimerMessage(context: Context, duration: Long, senderId: String? = null, isOutgoing: Boolean = false): String {
|
|
|
|
|
if (!isOutgoing && senderId == null) return ""
|
|
|
|
|
val storage = MessagingModuleConfiguration.shared.storage
|
|
|
|
|
val senderName: String? = if (!isOutgoing) {
|
|
|
|
|
storage.getContactWithSessionID(sender!!)?.displayName(Contact.ContactContext.REGULAR) ?: sender
|
|
|
|
|
storage.getContactWithSessionID(senderId!!)?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId)
|
|
|
|
|
} else { context.getString(R.string.MessageRecord_you) }
|
|
|
|
|
return if (duration <= 0) {
|
|
|
|
|
if (isOutgoing) context.getString(R.string.MessageRecord_you_disabled_disappearing_messages)
|
|
|
|
@ -93,9 +94,9 @@ object UpdateMessageBuilder {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun buildDataExtractionMessage(context: Context, kind: DataExtractionNotificationInfoMessage.Kind, sender: String? = null): String {
|
|
|
|
|
fun buildDataExtractionMessage(context: Context, kind: DataExtractionNotificationInfoMessage.Kind, senderId: String? = null): String {
|
|
|
|
|
val storage = MessagingModuleConfiguration.shared.storage
|
|
|
|
|
val senderName = storage.getContactWithSessionID(sender!!)?.displayName(Contact.ContactContext.REGULAR) ?: sender!!
|
|
|
|
|
val senderName = storage.getContactWithSessionID(senderId!!)?.displayName(Contact.ContactContext.REGULAR) ?: truncateIdForDisplay(senderId)
|
|
|
|
|
return when (kind) {
|
|
|
|
|
DataExtractionNotificationInfoMessage.Kind.SCREENSHOT ->
|
|
|
|
|
context.getString(R.string.MessageRecord_s_took_a_screenshot, senderName)
|
|
|
|
|