mirror of
https://github.com/micahflee/TM-SGNL-Android.git
synced 2025-08-04 19:08:33 +00:00
Merge remote-tracking branch 'origin/new_feauters_15_04_2024' into new_feauters_15_04_2024
This commit is contained in:
commit
999217ae9c
3 changed files with 21 additions and 3 deletions
|
@ -34,6 +34,9 @@ fun MessageRecord.hasSharedContact(): Boolean =
|
|||
fun MessageRecord.hasLocation(): Boolean =
|
||||
isMms && ((this as MmsMessageRecord).slideDeck.slides).any { slide -> slide.hasLocation() }
|
||||
|
||||
fun MessageRecord.hasGif(): Boolean =
|
||||
isMms && ((this as MmsMessageRecord).slideDeck.slides).any { slide -> slide.isVideoGif }
|
||||
|
||||
fun MessageRecord.hasAudio(): Boolean =
|
||||
isMms && (this as MmsMessageRecord).slideDeck.audioSlide != null
|
||||
|
||||
|
|
|
@ -34,9 +34,14 @@ class SignalArchiveRecipientConverter(
|
|||
}
|
||||
|
||||
fun convertReceiverRecipients(message: MessageRecord, thread: ThreadRecord?, chat: ArchiveChat, sender: ArchiveRecipient, direction: Direction): List<ArchiveRecipient> {
|
||||
val recipient = thread?.takeIf { chat.type != ChatType.Chat && it.recipient.participantIds.isNotEmpty() }?.recipient ?: message.toRecipient
|
||||
var recipient = message.toRecipient
|
||||
if (thread != null && chat.type != ChatType.Chat) {
|
||||
recipient = thread.recipient.resolve()
|
||||
if (recipient.participantIds.isEmpty()) recipient = message.toRecipient
|
||||
}
|
||||
if (chat.type == ChatType.Group) {
|
||||
return recipient.toParticipants().map { r -> ArchiveRecipient.forLongName(id = null, address = r.e164.getOrNull(), longName = r.displayName()) }
|
||||
val participants = recipient.toParticipants().map { r -> ArchiveRecipient.forLongName(id = null, address = r.e164.getOrNull(), longName = r.displayName()) }
|
||||
return participants.filter { it.cleanAddress != sender.cleanAddress }
|
||||
}
|
||||
if (direction == Direction.Incoming)
|
||||
return listOf(ArchiveRecipient.forLongName(id = null, address = getMyPhoneNumber(), longName = recipient.displayName()))
|
||||
|
|
|
@ -6,6 +6,12 @@ import org.tm.archive.database.model.MessageRecord
|
|||
import org.tm.archive.database.model.MmsMessageRecord
|
||||
import org.tm.archive.database.model.ThreadRecord
|
||||
import org.tm.archive.ringrtc.RemotePeer
|
||||
import org.tm.archive.util.hasAudio
|
||||
import org.tm.archive.util.hasDocument
|
||||
import org.tm.archive.util.hasGif
|
||||
import org.tm.archive.util.hasLocation
|
||||
import org.tm.archive.util.hasSharedContact
|
||||
import org.tm.archive.util.hasSticker
|
||||
|
||||
object Messages {
|
||||
|
||||
|
@ -14,7 +20,7 @@ object Messages {
|
|||
"]"
|
||||
|
||||
fun MessageRecord.isMultimediaMessage(): Boolean {
|
||||
return isMms && !isMmsNotification && (this as MmsMessageRecord).let { containsMediaSlide() || sharedContacts.isNotEmpty() }
|
||||
return isMms && !isMmsNotification && (this as MmsMessageRecord).let { containsMediaSlide() || sharedContacts.isNotEmpty() } && isMessageContainMedia(this)
|
||||
}
|
||||
|
||||
fun MessageRecord.isStory() = (this as? MmsMessageRecord)?.storyType?.isStory == true
|
||||
|
@ -49,6 +55,10 @@ object Messages {
|
|||
return MessageStatus.None
|
||||
}
|
||||
|
||||
private fun isMessageContainMedia(messageRecord: MmsMessageRecord): Boolean {
|
||||
return messageRecord.hasSharedContact() || messageRecord.hasDocument() || messageRecord.hasAudio() || messageRecord.hasSticker() || messageRecord.hasLocation() || messageRecord.hasSharedContact() || messageRecord.hasGif()
|
||||
}
|
||||
|
||||
fun MessageRecord.chatRecipient(type: ChatType, thread: ThreadRecord?) =
|
||||
if (type != ChatType.Chat) thread?.recipient ?: toRecipient.takeUnless { isOutgoing } ?: fromRecipient
|
||||
else fromRecipient.takeUnless { isOutgoing } ?: toRecipient
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue