Delete NotificationMmsMessageRecord.

This commit is contained in:
Greyson Parrelli
2023-11-12 09:14:55 -05:00
parent b7ec913cb9
commit 5f6fa73be9
2 changed files with 1 additions and 201 deletions

View File

@@ -67,7 +67,6 @@ import org.thoughtcrime.securesms.attachments.Attachment
import org.thoughtcrime.securesms.attachments.AttachmentId
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
import org.thoughtcrime.securesms.attachments.DatabaseAttachment.DisplayOrderComparator
import org.thoughtcrime.securesms.attachments.MmsNotificationAttachment
import org.thoughtcrime.securesms.contactshare.Contact
import org.thoughtcrime.securesms.conversation.MessageStyler
import org.thoughtcrime.securesms.database.EarlyDeliveryReceiptCache.Receipt
@@ -96,7 +95,6 @@ import org.thoughtcrime.securesms.database.model.MessageExportStatus
import org.thoughtcrime.securesms.database.model.MessageId
import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
import org.thoughtcrime.securesms.database.model.NotificationMmsMessageRecord
import org.thoughtcrime.securesms.database.model.ParentStoryId
import org.thoughtcrime.securesms.database.model.ParentStoryId.DirectReply
import org.thoughtcrime.securesms.database.model.ParentStoryId.GroupReply
@@ -4907,11 +4905,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
override fun getCurrent(): MessageRecord {
val mmsType = cursor.requireLong(MMS_MESSAGE_TYPE)
return if (mmsType == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND.toLong()) {
getNotificationMmsMessageRecord(cursor)
} else {
getMediaMmsMessageRecord(cursor)
}
return getMediaMmsMessageRecord(cursor)
}
override fun getMessageExportStateForCurrentRecord(): MessageExportState {
@@ -4939,73 +4933,6 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
return MessageId(cursor.requireLong(ID))
}
private fun getNotificationMmsMessageRecord(cursor: Cursor): NotificationMmsMessageRecord {
val id = cursor.requireLong(ID)
val dateSent = cursor.requireLong(DATE_SENT)
val dateReceived = cursor.requireLong(DATE_RECEIVED)
val threadId = cursor.requireLong(THREAD_ID)
val mailbox = cursor.requireLong(TYPE)
val fromRecipientId = cursor.requireLong(FROM_RECIPIENT_ID)
val fromDeviceId = cursor.requireInt(FROM_DEVICE_ID)
val toRecipientId = cursor.requireLong(TO_RECIPIENT_ID)
val fromRecipient = Recipient.live(RecipientId.from(fromRecipientId)).get()
val toRecipient = Recipient.live(RecipientId.from(toRecipientId)).get()
val contentLocation = cursor.requireString(MMS_CONTENT_LOCATION).toIsoBytes()
val transactionId = cursor.requireString(MMS_TRANSACTION_ID).toIsoBytes()
val messageSize = cursor.requireLong(MMS_MESSAGE_SIZE)
val expiry = cursor.requireLong(MMS_EXPIRY)
val status = cursor.requireInt(MMS_STATUS)
val deliveryReceiptCount = cursor.requireInt(DELIVERY_RECEIPT_COUNT)
var readReceiptCount = cursor.requireInt(READ_RECEIPT_COUNT)
val subscriptionId = cursor.requireInt(SMS_SUBSCRIPTION_ID)
val viewedReceiptCount = cursor.requireInt(VIEWED_RECEIPT_COUNT)
val receiptTimestamp = cursor.requireLong(RECEIPT_TIMESTAMP)
val storyType = StoryType.fromCode(cursor.requireInt(STORY_TYPE))
val parentStoryId = ParentStoryId.deserialize(cursor.requireLong(PARENT_STORY_ID))
val body = cursor.requireString(BODY)
if (!TextSecurePreferences.isReadReceiptsEnabled(context)) {
readReceiptCount = 0
}
val slideDeck = SlideDeck(MmsNotificationAttachment(status, messageSize))
val giftBadge: GiftBadge? = if (body != null && MessageTypes.isGiftBadge(mailbox)) {
try {
GiftBadge.ADAPTER.decode(Base64.decode(body))
} catch (e: IOException) {
Log.w(TAG, "Error parsing gift badge", e)
null
}
} else {
null
}
return NotificationMmsMessageRecord(
id,
fromRecipient,
fromDeviceId,
toRecipient,
dateSent,
dateReceived,
deliveryReceiptCount,
threadId,
contentLocation,
messageSize,
expiry,
status,
transactionId,
mailbox,
subscriptionId,
slideDeck,
readReceiptCount,
viewedReceiptCount,
receiptTimestamp,
storyType,
parentStoryId,
giftBadge
)
}
private fun getMediaMmsMessageRecord(cursor: Cursor): MediaMmsMessageRecord {
val id = cursor.requireLong(ID)
val dateSent = cursor.requireLong(DATE_SENT)

View File

@@ -1,127 +0,0 @@
/*
* Copyright (C) 2012 Moxie Marlinspike
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.database.model;
import android.content.Context;
import android.text.SpannableString;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.MessageTable;
import org.thoughtcrime.securesms.database.MessageTable.Status;
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge;
import org.thoughtcrime.securesms.mms.SlideDeck;
import org.thoughtcrime.securesms.recipients.Recipient;
import java.util.Collections;
import java.util.HashSet;
/**
* Represents the message record model for MMS messages that are
* notifications (ie: they're pointers to undownloaded media).
*
* @author Moxie Marlinspike
*
*/
public class NotificationMmsMessageRecord extends MmsMessageRecord {
private final byte[] contentLocation;
private final long messageSize;
private final long expiry;
private final int status;
private final byte[] transactionId;
public NotificationMmsMessageRecord(long id, Recipient fromRecipient, int fromDeviceId, Recipient toRecipient,
long dateSent, long dateReceived, int deliveryReceiptCount,
long threadId, byte[] contentLocation, long messageSize,
long expiry, int status, byte[] transactionId, long mailbox,
int subscriptionId, SlideDeck slideDeck, int readReceiptCount,
int viewedReceiptCount, long receiptTimestamp, @NonNull StoryType storyType,
@Nullable ParentStoryId parentStoryId, @Nullable GiftBadge giftBadge)
{
super(id, "", fromRecipient, fromDeviceId, toRecipient,
dateSent, dateReceived, -1, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox,
new HashSet<>(), new HashSet<>(), subscriptionId,
0, 0, false, slideDeck, readReceiptCount, null, Collections.emptyList(), Collections.emptyList(), false,
Collections.emptyList(), false, 0, viewedReceiptCount, receiptTimestamp, storyType, parentStoryId, giftBadge, null, 0);
this.contentLocation = contentLocation;
this.messageSize = messageSize;
this.expiry = expiry;
this.status = status;
this.transactionId = transactionId;
}
public byte[] getTransactionId() {
return transactionId;
}
public int getStatus() {
return this.status;
}
public byte[] getContentLocation() {
return contentLocation;
}
public long getMessageSize() {
return (messageSize + 1023) / 1024;
}
public long getExpiration() {
return expiry * 1000;
}
@Override
public boolean isOutgoing() {
return false;
}
@Override
public boolean isSecure() {
return false;
}
@Override
public boolean isPending() {
return false;
}
@Override
public boolean isMmsNotification() {
return true;
}
@Override
public boolean isMediaPending() {
return true;
}
@Override
public SpannableString getDisplayBody(@NonNull Context context) {
if (status == MessageTable.MmsStatus.DOWNLOAD_INITIALIZED) {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_multimedia_message));
} else if (status == MessageTable.MmsStatus.DOWNLOAD_CONNECTING) {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_downloading_mms_message));
} else {
return emphasisAdded(context.getString(R.string.NotificationMmsMessageRecord_error_downloading_mms_message));
}
}
}