make RetrieveProfileAvatarJob work

This commit is contained in:
ryanzhao 2023-05-09 14:14:49 +10:00
parent b494088c3d
commit fa71ea1850
5 changed files with 8 additions and 4 deletions

View File

@ -77,6 +77,11 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
JobQueue.shared.add(RetrieveProfileAvatarJob(newValue, ourRecipient.address))
}
override fun setProfileAvatar(recipient: Recipient, profileAvatar: String) {
val database = DatabaseComponent.get(context).recipientDatabase()
database.setProfileAvatar(recipient, profileAvatar)
}
override fun getOrGenerateRegistrationID(): Int {
var registrationID = TextSecurePreferences.getLocalRegistrationId(context)
if (registrationID == 0) {

View File

@ -41,7 +41,6 @@ class ProfileManager : SSKEnvironment.ProfileManagerProtocol {
override fun setProfilePictureURL(context: Context, recipient: Recipient, profilePictureURL: String) {
val job = RetrieveProfileAvatarJob(profilePictureURL, recipient.address)
job.context = context
JobQueue.shared.add(job)
val sessionID = recipient.address.serialize()
val contactDatabase = DatabaseComponent.get(context).sessionContactDatabase()

View File

@ -38,7 +38,7 @@ interface StorageProtocol {
fun getUserX25519KeyPair(): ECKeyPair
fun getUserProfile(): Profile
fun setUserProfilePictureURL(newProfilePicture: String)
fun
fun setProfileAvatar(recipient: Recipient, profileAvatar: String)
// Signal
fun getOrGenerateRegistrationID(): Int

View File

@ -125,6 +125,7 @@ class JobQueue : JobDelegate {
is NotifyPNServerJob, is AttachmentUploadJob, is MessageSendJob -> {
txQueue.send(job)
}
is RetrieveProfileAvatarJob,
is AttachmentDownloadJob -> {
mediaQueue.send(job)
}
@ -224,6 +225,7 @@ class JobQueue : JobDelegate {
GroupAvatarDownloadJob.KEY,
BackgroundGroupAddJob.KEY,
OpenGroupDeleteJob.KEY,
RetrieveProfileAvatarJob.KEY,
)
allJobTypes.forEach { type ->
resumePendingJobs(type)

View File

@ -1,6 +1,5 @@
package org.session.libsession.messaging.jobs
import android.content.Context
import android.text.TextUtils
import org.session.libsession.avatars.AvatarHelper
import org.session.libsession.messaging.MessagingModuleConfiguration
@ -13,7 +12,6 @@ import org.session.libsession.utilities.Address
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsignal.streams.ProfileCipherInputStream
import org.session.libsignal.utilities.Log
import org.thoughtcrime.securesms.dependencies.DatabaseComponent.Companion.get
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream