mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 12:47:25 +00:00
Tidy up
This commit is contained in:
@@ -44,7 +44,7 @@ interface GroupManagerV2 {
|
||||
|
||||
suspend fun handleMemberLeft(message: GroupUpdated, group: AccountId)
|
||||
|
||||
suspend fun leaveGroup(group: AccountId, deleteOnLeave: Boolean)
|
||||
suspend fun leaveGroup(groupId: AccountId, deleteOnLeave: Boolean)
|
||||
|
||||
suspend fun promoteMember(group: AccountId, members: List<AccountId>)
|
||||
|
||||
|
@@ -120,7 +120,6 @@ class JobQueue : JobDelegate {
|
||||
is NotifyPNServerJob,
|
||||
is AttachmentUploadJob,
|
||||
is GroupLeavingJob,
|
||||
is LibSessionGroupLeavingJob,
|
||||
is MessageSendJob -> {
|
||||
txQueue.send(job)
|
||||
}
|
||||
@@ -226,7 +225,6 @@ class JobQueue : JobDelegate {
|
||||
RetrieveProfileAvatarJob.KEY,
|
||||
GroupLeavingJob.KEY,
|
||||
InviteContactsJob.KEY,
|
||||
LibSessionGroupLeavingJob.KEY
|
||||
)
|
||||
allJobTypes.forEach { type ->
|
||||
resumePendingJobs(type)
|
||||
|
@@ -1,67 +0,0 @@
|
||||
package org.session.libsession.messaging.jobs
|
||||
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsession.messaging.utilities.Data
|
||||
import org.session.libsession.messaging.utilities.UpdateMessageData
|
||||
import org.session.libsignal.utilities.AccountId
|
||||
|
||||
class LibSessionGroupLeavingJob(val accountId: AccountId, val deleteOnLeave: Boolean): Job {
|
||||
|
||||
|
||||
override var delegate: JobDelegate? = null
|
||||
override var id: String? = null
|
||||
override var failureCount: Int = 0
|
||||
override val maxFailureCount: Int = 4
|
||||
|
||||
override suspend fun execute(dispatcherName: String) {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
// start leaving
|
||||
// create message ID with leaving state
|
||||
val messageId = storage.insertGroupInfoLeaving(accountId) ?: run {
|
||||
delegate?.handleJobFailedPermanently(
|
||||
this,
|
||||
dispatcherName,
|
||||
Exception("Couldn't insert GroupInfoLeaving message in leaving group job")
|
||||
)
|
||||
return
|
||||
}
|
||||
// do actual group leave request
|
||||
|
||||
// on success
|
||||
val leaveGroup = kotlin.runCatching {
|
||||
MessagingModuleConfiguration.shared.groupManagerV2.leaveGroup(accountId, deleteOnLeave)
|
||||
}
|
||||
|
||||
if (leaveGroup.isSuccess) {
|
||||
// message is already deleted, succeed
|
||||
delegate?.handleJobSucceeded(this, dispatcherName)
|
||||
} else {
|
||||
// Error leaving group, update the info message
|
||||
storage.updateGroupInfoChange(messageId, UpdateMessageData.Kind.GroupErrorQuit)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(): Data =
|
||||
Data.Builder()
|
||||
.putString(SESSION_ID_KEY, accountId.hexString)
|
||||
.putBoolean(DELETE_ON_LEAVE_KEY, deleteOnLeave)
|
||||
.build()
|
||||
|
||||
class Factory : Job.Factory<LibSessionGroupLeavingJob> {
|
||||
override fun create(data: Data): LibSessionGroupLeavingJob {
|
||||
return LibSessionGroupLeavingJob(
|
||||
AccountId(data.getString(SESSION_ID_KEY)),
|
||||
data.getBoolean(DELETE_ON_LEAVE_KEY)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
companion object {
|
||||
const val KEY = "LibSessionGroupLeavingJob"
|
||||
private const val SESSION_ID_KEY = "SessionId"
|
||||
private const val DELETE_ON_LEAVE_KEY = "DeleteOnLeave"
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user