mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 21:17:42 +00:00
implementation of persistAttachments + refactoring
This commit is contained in:
@@ -438,6 +438,30 @@ public class AttachmentDatabase extends Database {
|
||||
return insertedAttachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert attachments in database and return the IDs of the inserted attachments
|
||||
*
|
||||
* @param mmsId message ID
|
||||
* @param attachments attachments to persist
|
||||
* @return IDs of the persisted attachments
|
||||
* @throws MmsException
|
||||
*/
|
||||
@NonNull List<Long> insertAttachments(long mmsId, @NonNull List<Attachment> attachments)
|
||||
throws MmsException
|
||||
{
|
||||
Log.d(TAG, "insertParts(" + attachments.size() + ")");
|
||||
|
||||
List<Long> insertedAttachmentsIDs = new LinkedList<>();
|
||||
|
||||
for (Attachment attachment : attachments) {
|
||||
AttachmentId attachmentId = insertAttachment(mmsId, attachment, attachment.isQuote());
|
||||
insertedAttachmentsIDs.add(attachmentId.getRowId());
|
||||
Log.i(TAG, "Inserted attachment at ID: " + attachmentId);
|
||||
}
|
||||
|
||||
return insertedAttachmentsIDs;
|
||||
}
|
||||
|
||||
public @NonNull Attachment updateAttachmentData(@NonNull Attachment attachment,
|
||||
@NonNull MediaStream mediaStream)
|
||||
throws MmsException
|
||||
|
@@ -81,8 +81,10 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
return registrationID
|
||||
}
|
||||
|
||||
override fun persist(attachments: List<Attachment>): List<Long> {
|
||||
TODO("Not yet implemented")
|
||||
override fun persistAttachments(messageId: Long, attachments: List<Attachment>): List<Long> {
|
||||
val database = DatabaseFactory.getAttachmentDatabase(context)
|
||||
val databaseAttachments = attachments.map { it.toDatabaseAttachment() }
|
||||
return database.insertAttachments(messageId, databaseAttachments)
|
||||
}
|
||||
|
||||
override fun persist(message: VisibleMessage, quotes: QuoteModel?, linkPreview: List<LinkPreview?>, groupPublicKey: String?, openGroupID: String?): Long? {
|
||||
@@ -127,7 +129,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
|
||||
// JOBS
|
||||
|
||||
override fun persist(job: Job) {
|
||||
override fun persistJob(job: Job) {
|
||||
DatabaseFactory.getSessionJobDatabase(context).persistJob(job)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user