Move to defined from_recipient_id and to_recipient_id columns on message table.

This commit is contained in:
Greyson Parrelli
2023-04-14 14:23:05 -04:00
committed by Cody Henthorne
parent d079f85eca
commit 279ad7945e
86 changed files with 944 additions and 719 deletions

View File

@@ -293,7 +293,7 @@ sealed class NotificationBuilder(protected val context: Context) {
.setIcon(notificationItem.getPersonIcon(context).toIconCompat())
if (includeShortcut) {
personBuilder.setKey(ConversationUtil.getShortcutId(notificationItem.individualRecipient))
personBuilder.setKey(ConversationUtil.getShortcutId(notificationItem.authorRecipient))
}
person = personBuilder.build()
@@ -319,7 +319,7 @@ sealed class NotificationBuilder(protected val context: Context) {
if (line != null) {
style.addLine(line)
}
addPerson(notificationItem.individualRecipient)
addPerson(notificationItem.authorRecipient)
}
builder.setStyle(style)

View File

@@ -74,7 +74,7 @@ data class NotificationConversation(
val stringBuilder = SpannableStringBuilder()
if (privacy.isDisplayContact && recipient.isGroup) {
stringBuilder.append(Util.getBoldedString(mostRecentNotification.individualRecipient.getDisplayName(context) + ": "))
stringBuilder.append(Util.getBoldedString(mostRecentNotification.authorRecipient.getDisplayName(context) + ": "))
}
return if (privacy.isDisplayMessage) {

View File

@@ -112,7 +112,7 @@ object NotificationFactory {
conversation = conversation,
targetThread = targetThread,
defaultBubbleState = defaultBubbleState,
shouldAlert = (conversation.hasNewNotifications() || alertOverrides.contains(conversation.thread)) && !conversation.mostRecentNotification.individualRecipient.isSelf
shouldAlert = (conversation.hasNewNotifications() || alertOverrides.contains(conversation.thread)) && !conversation.mostRecentNotification.authorRecipient.isSelf
)
if (conversation.hasNewNotifications()) {
threadsThatNewlyAlerted += conversation.thread
@@ -157,7 +157,7 @@ object NotificationFactory {
conversation = conversation,
targetThread = targetThread,
defaultBubbleState = defaultBubbleState,
shouldAlert = (conversation.hasNewNotifications() || alertOverrides.contains(conversation.thread)) && !conversation.mostRecentNotification.individualRecipient.isSelf
shouldAlert = (conversation.hasNewNotifications() || alertOverrides.contains(conversation.thread)) && !conversation.mostRecentNotification.authorRecipient.isSelf
)
} catch (e: SecurityException) {
Log.w(TAG, "Too many pending intents device quirk", e)

View File

@@ -49,12 +49,12 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
val slideDeck: SlideDeck? = if (record.isViewOnce) null else (record as? MmsMessageRecord)?.slideDeck
val isJoined: Boolean = record.isJoined
val isPersonSelf: Boolean
get() = individualRecipient.isSelf
get() = authorRecipient.isSelf
protected val notifiedTimestamp: Long = record.notifiedTimestamp
abstract val timestamp: Long
abstract val individualRecipient: Recipient
abstract val authorRecipient: Recipient
abstract val isNewNotification: Boolean
protected abstract fun getPrimaryTextActual(context: Context): CharSequence
@@ -92,8 +92,8 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
context.getString(R.string.SingleRecipientNotificationBuilder_new_message)
} else {
SpannableStringBuilder().apply {
append(Util.getBoldedString(individualRecipient.getShortDisplayNameIncludingUsername(context)))
if (threadRecipient != individualRecipient) {
append(Util.getBoldedString(authorRecipient.getShortDisplayNameIncludingUsername(context)))
if (threadRecipient != authorRecipient) {
append(Util.getBoldedString("@${threadRecipient.getDisplayName(context)}"))
}
append(": ")
@@ -104,7 +104,7 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
fun getPersonName(context: Context): CharSequence {
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
individualRecipient.getDisplayName(context)
authorRecipient.getDisplayName(context)
} else {
context.getString(R.string.SingleRecipientNotificationBuilder_signal)
}
@@ -115,8 +115,8 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
}
fun getPersonUri(): String? {
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact && individualRecipient.isSystemContact) {
individualRecipient.contactUri.toString()
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact && authorRecipient.isSystemContact) {
authorRecipient.contactUri.toString()
} else {
null
}
@@ -124,7 +124,7 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
fun getPersonIcon(context: Context): Bitmap? {
return if (SignalStore.settings().messageNotificationsPrivacy.isDisplayContact) {
individualRecipient.getContactDrawable(context).toLargeBitmap(context)
authorRecipient.getContactDrawable(context).toLargeBitmap(context)
} else {
null
}
@@ -153,8 +153,8 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
return timestamp == other.timestamp &&
id == other.id &&
isMms == other.isMms &&
individualRecipient == other.individualRecipient &&
individualRecipient.hasSameContent(other.individualRecipient) &&
authorRecipient == other.authorRecipient &&
authorRecipient.hasSameContent(other.authorRecipient) &&
slideDeck?.thumbnailSlide?.isInProgress == other.slideDeck?.thumbnailSlide?.isInProgress &&
record.isRemoteDelete == other.record.isRemoteDelete
}
@@ -203,7 +203,7 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
*/
class MessageNotification(threadRecipient: Recipient, record: MessageRecord) : NotificationItem(threadRecipient, record) {
override val timestamp: Long = record.timestamp
override val individualRecipient: Recipient = if (record.isOutgoing) Recipient.self() else record.individualRecipient.resolve()
override val authorRecipient: Recipient = record.fromRecipient.resolve()
override val isNewNotification: Boolean = notifiedTimestamp == 0L
private var thumbnailInfo: ThumbnailInfo? = null
@@ -302,7 +302,7 @@ class MessageNotification(threadRecipient: Recipient, record: MessageRecord) : N
*/
class ReactionNotification(threadRecipient: Recipient, record: MessageRecord, val reaction: ReactionRecord) : NotificationItem(threadRecipient, record) {
override val timestamp: Long = reaction.dateReceived
override val individualRecipient: Recipient = Recipient.resolved(reaction.author)
override val authorRecipient: Recipient = Recipient.resolved(reaction.author)
override val isNewNotification: Boolean = timestamp > notifiedTimestamp
override fun getPrimaryTextActual(context: Context): CharSequence {

View File

@@ -38,7 +38,7 @@ data class NotificationState(val conversations: List<NotificationConversation>,
get() = notificationItems.lastOrNull()
val mostRecentSender: Recipient?
get() = mostRecentNotification?.individualRecipient
get() = mostRecentNotification?.authorRecipient
fun getNonVisibleConversation(visibleThread: ConversationId?): List<NotificationConversation> {
return conversations.filterNot { it.thread == visibleThread }
@@ -81,7 +81,7 @@ data class NotificationState(val conversations: List<NotificationConversation>,
}
fun getThreadsWithMostRecentNotificationFromSelf(): Set<ConversationId> {
return conversations.filter { it.mostRecentNotification.individualRecipient.isSelf }
return conversations.filter { it.mostRecentNotification.authorRecipient.isSelf }
.map { it.thread }
.toSet()
}

View File

@@ -112,8 +112,8 @@ object NotificationStateProvider {
}
notificationItems.sort()
if (notificationItems.isNotEmpty() && stickyThreads.containsKey(thread) && !notificationItems.last().individualRecipient.isSelf) {
val indexOfOldestNonSelfMessage: Int = notificationItems.indexOfLast { it.individualRecipient.isSelf } + 1
if (notificationItems.isNotEmpty() && stickyThreads.containsKey(thread) && !notificationItems.last().authorRecipient.isSelf) {
val indexOfOldestNonSelfMessage: Int = notificationItems.indexOfLast { it.authorRecipient.isSelf } + 1
notificationItems = notificationItems.slice(indexOfOldestNonSelfMessage..notificationItems.lastIndex).toMutableList()
}