Convert AttachmentTable and models to kotlin.

This commit is contained in:
Greyson Parrelli
2024-01-03 14:43:05 -05:00
committed by Alex Hart
parent 888a40a5c4
commit 3554f82ea3
62 changed files with 2626 additions and 2986 deletions

View File

@@ -344,7 +344,7 @@ public class MessageSender {
List<AttachmentId> attachmentIds = new ArrayList<>(preUploadAttachmentIds.size());
for (int i = 0; i < preUploadAttachments.size(); i++) {
AttachmentId attachmentId = attachmentDatabase.insertAttachmentForPreUpload(preUploadAttachments.get(i)).getAttachmentId();
AttachmentId attachmentId = attachmentDatabase.insertAttachmentForPreUpload(preUploadAttachments.get(i)).attachmentId;
attachmentCopies.get(i).add(attachmentId);
attachmentIds.add(attachmentId);
}
@@ -418,14 +418,14 @@ public class MessageSender {
DatabaseAttachment databaseAttachment = attachmentDatabase.insertAttachmentForPreUpload(attachment);
Job compressionJob = AttachmentCompressionJob.fromAttachment(databaseAttachment, false, -1);
Job uploadJob = new AttachmentUploadJob(databaseAttachment.getAttachmentId());
Job uploadJob = new AttachmentUploadJob(databaseAttachment.attachmentId);
ApplicationDependencies.getJobManager()
.startChain(compressionJob)
.then(uploadJob)
.enqueue();
return new PreUploadResult(media, databaseAttachment.getAttachmentId(), Arrays.asList(compressionJob.getId(), uploadJob.getId()));
return new PreUploadResult(media, databaseAttachment.attachmentId, Arrays.asList(compressionJob.getId(), uploadJob.getId()));
} catch (MmsException e) {
Log.w(TAG, "preUploadPushAttachment() - Failed to upload!", e);
return null;
@@ -645,7 +645,7 @@ public class MessageSender {
.toList();
List<AttachmentMarkUploadedJob> fakeUploadJobs = Stream.of(attachments)
.map(a -> new AttachmentMarkUploadedJob(messageId, ((DatabaseAttachment) a).getAttachmentId()))
.map(a -> new AttachmentMarkUploadedJob(messageId, ((DatabaseAttachment) a).attachmentId))
.toList();
ApplicationDependencies.getJobManager().startChain(compressionJobs)

View File

@@ -6,6 +6,7 @@ import org.thoughtcrime.securesms.attachments.AttachmentId
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
import org.thoughtcrime.securesms.attachments.UriAttachment
import org.thoughtcrime.securesms.database.AttachmentTable
import org.thoughtcrime.securesms.database.AttachmentTable.TransformProperties
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.JobManager
import org.thoughtcrime.securesms.jobs.AttachmentCompressionJob
@@ -43,7 +44,7 @@ class UploadDependencyGraph private constructor(
*/
private data class AttachmentKey<A : Attachment>(
val attachment: A,
private val transformProperties: AttachmentTable.TransformProperties = attachment.transformProperties
private val transformProperties: AttachmentTable.TransformProperties = attachment.transformProperties ?: AttachmentTable.TransformProperties.empty()
)
private var hasConsumedJobQueue = false
@@ -75,14 +76,14 @@ class UploadDependencyGraph private constructor(
* Allows representation of a unique database attachment by its internal id and its transform properties.
*/
private fun DatabaseAttachment.asDatabaseAttachmentKey(): AttachmentKey<DatabaseAttachment> {
return AttachmentKey(this, this.transformProperties)
return AttachmentKey(this, this.transformProperties ?: TransformProperties.empty())
}
/**
* Allows representation of a unique URI attachment by its internal Uri and its transform properties.
*/
private fun UriAttachment.asUriAttachmentKey(): AttachmentKey<UriAttachment> {
return AttachmentKey(this, transformProperties)
return AttachmentKey(this, transformProperties ?: TransformProperties.empty())
}
/**
@@ -119,7 +120,7 @@ class UploadDependencyGraph private constructor(
message.linkPreviews.mapNotNull { it.thumbnail.orElse(null) } +
message.sharedContacts.mapNotNull { it.avatar?.attachment }
val uniqueAttachments: Set<AttachmentKey<Attachment>> = attachmentList.map { AttachmentKey(it, it.transformProperties) }.toSet()
val uniqueAttachments: Set<AttachmentKey<Attachment>> = attachmentList.map { AttachmentKey(it, it.transformProperties ?: TransformProperties.empty()) }.toSet()
for (attachmentKey in uniqueAttachments) {
when (val attachment = attachmentKey.attachment) {