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

@@ -19,7 +19,7 @@ import org.thoughtcrime.securesms.sms.GroupV2UpdateMessageUtil
* Represents all the data needed for an outgoing message.
*/
data class OutgoingMessage(
val recipient: Recipient,
val threadRecipient: Recipient,
val sentTimeMillis: Long,
val body: String = "",
val distributionType: Int = ThreadTable.DistributionTypes.DEFAULT,
@@ -82,7 +82,7 @@ data class OutgoingMessage(
bodyRanges: BodyRangeList? = null,
scheduledDate: Long = -1
) : this(
recipient = recipient,
threadRecipient = recipient,
body = body ?: "",
attachments = attachments,
sentTimeMillis = timestamp,
@@ -123,7 +123,7 @@ data class OutgoingMessage(
bodyRanges: BodyRangeList? = null,
contacts: List<Contact> = emptyList()
) : this(
recipient = recipient,
threadRecipient = recipient,
body = buildMessage(slideDeck, body ?: ""),
attachments = slideDeck.asAttachments(),
sentTimeMillis = timestamp,
@@ -168,9 +168,9 @@ data class OutgoingMessage(
* A literal, insecure SMS message.
*/
@JvmStatic
fun sms(recipient: Recipient, body: String, subscriptionId: Int): OutgoingMessage {
fun sms(threadRecipient: Recipient, body: String, subscriptionId: Int): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = System.currentTimeMillis(),
body = body,
subscriptionId = subscriptionId,
@@ -183,14 +183,14 @@ data class OutgoingMessage(
*/
@JvmStatic
fun text(
recipient: Recipient,
threadRecipient: Recipient,
body: String,
expiresIn: Long,
sentTimeMillis: Long = System.currentTimeMillis(),
bodyRanges: BodyRangeList? = null
): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
body = body,
expiresIn = expiresIn,
@@ -204,11 +204,11 @@ data class OutgoingMessage(
* Helper for creating a group update message when a state change occurs and needs to be sent to others.
*/
@JvmStatic
fun groupUpdateMessage(recipient: Recipient, group: DecryptedGroupV2Context, sentTimeMillis: Long): OutgoingMessage {
fun groupUpdateMessage(threadRecipient: Recipient, group: DecryptedGroupV2Context, sentTimeMillis: Long): OutgoingMessage {
val groupContext = MessageGroupContext(group)
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
body = groupContext.encodedGroupContext,
sentTimeMillis = sentTimeMillis,
messageGroupContext = groupContext,
@@ -223,7 +223,7 @@ data class OutgoingMessage(
*/
@JvmStatic
fun groupUpdateMessage(
recipient: Recipient,
threadRecipient: Recipient,
groupContext: MessageGroupContext,
avatar: List<Attachment> = emptyList(),
sentTimeMillis: Long,
@@ -235,7 +235,7 @@ data class OutgoingMessage(
mentions: List<Mention> = emptyList()
): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
body = groupContext.encodedGroupContext,
isGroup = true,
isGroupUpdate = true,
@@ -257,7 +257,7 @@ data class OutgoingMessage(
*/
@JvmStatic
fun textStoryMessage(
recipient: Recipient,
threadRecipient: Recipient,
body: String,
sentTimeMillis: Long,
storyType: StoryType,
@@ -265,7 +265,7 @@ data class OutgoingMessage(
bodyRanges: BodyRangeList?
): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
body = body,
sentTimeMillis = sentTimeMillis,
storyType = storyType,
@@ -279,9 +279,9 @@ data class OutgoingMessage(
* Specialized message sent to request someone activate payments.
*/
@JvmStatic
fun requestToActivatePaymentsMessage(recipient: Recipient, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
fun requestToActivatePaymentsMessage(threadRecipient: Recipient, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
expiresIn = expiresIn,
isRequestToActivatePayments = true,
@@ -295,9 +295,9 @@ data class OutgoingMessage(
* be sent to those that sent requests prior to activation.
*/
@JvmStatic
fun paymentsActivatedMessage(recipient: Recipient, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
fun paymentsActivatedMessage(threadRecipient: Recipient, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
expiresIn = expiresIn,
isPaymentsActivated = true,
@@ -310,9 +310,9 @@ data class OutgoingMessage(
* Type of message sent when sending a payment to another Signal contact.
*/
@JvmStatic
fun paymentNotificationMessage(recipient: Recipient, paymentUuid: String, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
fun paymentNotificationMessage(threadRecipient: Recipient, paymentUuid: String, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
body = paymentUuid,
sentTimeMillis = sentTimeMillis,
expiresIn = expiresIn,
@@ -325,9 +325,9 @@ data class OutgoingMessage(
* Helper for creating expiration update messages.
*/
@JvmStatic
fun expirationUpdateMessage(recipient: Recipient, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
fun expirationUpdateMessage(threadRecipient: Recipient, sentTimeMillis: Long, expiresIn: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
expiresIn = expiresIn,
isExpirationUpdate = true,
@@ -340,9 +340,9 @@ data class OutgoingMessage(
* Message for when you have verified the identity of a contact.
*/
@JvmStatic
fun identityVerifiedMessage(recipient: Recipient, sentTimeMillis: Long): OutgoingMessage {
fun identityVerifiedMessage(threadRecipient: Recipient, sentTimeMillis: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
isIdentityVerified = true,
isUrgent = false,
@@ -354,9 +354,9 @@ data class OutgoingMessage(
* Message for when the verification status of an identity is getting set to the default.
*/
@JvmStatic
fun identityDefaultMessage(recipient: Recipient, sentTimeMillis: Long): OutgoingMessage {
fun identityDefaultMessage(threadRecipient: Recipient, sentTimeMillis: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
isIdentityDefault = true,
isUrgent = false,
@@ -369,9 +369,9 @@ data class OutgoingMessage(
* but it doesn't hurt to support receiving them in sync messages.
*/
@JvmStatic
fun endSessionMessage(recipient: Recipient, sentTimeMillis: Long): OutgoingMessage {
fun endSessionMessage(threadRecipient: Recipient, sentTimeMillis: Long): OutgoingMessage {
return OutgoingMessage(
recipient = recipient,
threadRecipient = threadRecipient,
sentTimeMillis = sentTimeMillis,
isEndSession = true,
isUrgent = false,