Add call link support to storage service.

This commit is contained in:
Nicholas Tinsley
2024-09-09 13:15:32 -04:00
committed by Cody Henthorne
parent 1f2b5e90a3
commit e247d311d8
29 changed files with 645 additions and 83 deletions

View File

@@ -62,7 +62,8 @@ private fun SignalCallRowPreview() {
restrictions = org.signal.ringrtc.CallLinkState.Restrictions.NONE,
expiration = Instant.MAX,
revoked = false
)
),
deletionTimestamp = 0L
)
}
Previews.Preview {

View File

@@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.jobs.CallLinkUpdateSendJob
import org.thoughtcrime.securesms.service.webrtc.links.CallLinkCredentials
import org.thoughtcrime.securesms.service.webrtc.links.SignalCallLinkManager
import org.thoughtcrime.securesms.service.webrtc.links.UpdateCallLinkResult
import org.thoughtcrime.securesms.storage.StorageSyncHelper
/**
* Repository for performing update operations on call links:
@@ -65,6 +66,7 @@ class UpdateCallLinkRepository(
is UpdateCallLinkResult.Delete -> {
SignalDatabase.callLinks.markRevoked(credentials.roomId)
AppDependencies.jobManager.add(CallLinkUpdateSendJob(credentials.roomId))
StorageSyncHelper.scheduleSyncForDataChange()
}
else -> {}
}

View File

@@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.service.webrtc.links.CallLinkCredentials
import org.thoughtcrime.securesms.service.webrtc.links.CreateCallLinkResult
import org.thoughtcrime.securesms.service.webrtc.links.SignalCallLinkManager
import org.thoughtcrime.securesms.storage.StorageSyncHelper
import org.whispersystems.signalservice.internal.push.SyncMessage
/**
@@ -40,22 +41,25 @@ class CreateCallLinkRepository(
SignalDatabase.callLinks.insertCallLink(
CallLinkTable.CallLink(
recipientId = RecipientId.UNKNOWN,
roomId = credentials.roomId,
credentials = credentials,
state = it.state
roomId = it.credentials.roomId,
credentials = it.credentials,
state = it.state,
deletionTimestamp = 0L
)
)
AppDependencies.jobManager.add(
CallLinkUpdateSendJob(
credentials.roomId,
it.credentials.roomId,
SyncMessage.CallLinkUpdate.Type.UPDATE
)
)
StorageSyncHelper.scheduleSyncForDataChange()
EnsureCallLinkCreatedResult.Success(
Recipient.resolved(
SignalDatabase.recipients.getByCallLinkRoomId(credentials.roomId).get()
SignalDatabase.recipients.getByCallLinkRoomId(it.credentials.roomId).get()
)
)
}

View File

@@ -39,7 +39,8 @@ class CreateCallLinkViewModel(
restrictions = Restrictions.ADMIN_APPROVAL,
revoked = false,
expiration = Instant.MAX
)
),
deletionTimestamp = 0L
)
)

View File

@@ -140,7 +140,7 @@ class CallLinkDetailsFragment : ComposeFragment(), CallLinkDetailsCallback {
viewModel.setDisplayRevocationDialog(false)
lifecycleDisposable += viewModel.delete().observeOn(AndroidSchedulers.mainThread()).subscribeBy(onSuccess = {
when (it) {
is UpdateCallLinkResult.Update -> ActivityCompat.finishAfterTransition(requireActivity())
is UpdateCallLinkResult.Delete -> ActivityCompat.finishAfterTransition(requireActivity())
else -> {
Log.w(TAG, "Failed to revoke. $it")
toastFailure()
@@ -213,7 +213,8 @@ private fun CallLinkDetailsPreview() {
revoked = false,
restrictions = Restrictions.NONE,
expiration = Instant.MAX
)
),
deletionTimestamp = 0L
)
}

View File

@@ -150,7 +150,7 @@ class CallLogRepository(
updateCallLinkRepository.deleteCallLink(it.credentials!!)
}
).reduce(0) { acc, current ->
acc + (if (current is UpdateCallLinkResult.Update) 0 else 1)
acc + (if (current is UpdateCallLinkResult.Delete) 0 else 1)
}.doOnTerminate {
SignalDatabase.calls.updateAdHocCallEventDeletionTimestamps()
}.doOnDispose {