mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
CallLink NullMessage sending.
This commit is contained in:
committed by
Cody Henthorne
parent
c3408040fc
commit
0940c88c20
@@ -58,6 +58,7 @@ import org.signal.libsignal.protocol.IdentityKey;
|
|||||||
import org.thoughtcrime.securesms.components.TooltipPopup;
|
import org.thoughtcrime.securesms.components.TooltipPopup;
|
||||||
import org.thoughtcrime.securesms.components.sensors.DeviceOrientationMonitor;
|
import org.thoughtcrime.securesms.components.sensors.DeviceOrientationMonitor;
|
||||||
import org.thoughtcrime.securesms.components.webrtc.CallLinkInfoSheet;
|
import org.thoughtcrime.securesms.components.webrtc.CallLinkInfoSheet;
|
||||||
|
import org.thoughtcrime.securesms.components.webrtc.CallLinkNullMessageSender;
|
||||||
import org.thoughtcrime.securesms.components.webrtc.CallParticipantsListUpdatePopupWindow;
|
import org.thoughtcrime.securesms.components.webrtc.CallParticipantsListUpdatePopupWindow;
|
||||||
import org.thoughtcrime.securesms.components.webrtc.CallParticipantsState;
|
import org.thoughtcrime.securesms.components.webrtc.CallParticipantsState;
|
||||||
import org.thoughtcrime.securesms.components.webrtc.CallStateUpdatePopupWindow;
|
import org.thoughtcrime.securesms.components.webrtc.CallStateUpdatePopupWindow;
|
||||||
@@ -99,6 +100,7 @@ import org.thoughtcrime.securesms.webrtc.CallParticipantsViewState;
|
|||||||
import org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager;
|
import org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager;
|
||||||
import org.whispersystems.signalservice.api.messages.calls.HangupMessage;
|
import org.whispersystems.signalservice.api.messages.calls.HangupMessage;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -775,6 +777,10 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.isCallLink()) {
|
||||||
|
CallLinkNullMessageSender.onSendAnyway(new HashSet<>(changedRecipients));
|
||||||
|
}
|
||||||
|
|
||||||
if (state.getGroupCallState().isConnected()) {
|
if (state.getGroupCallState().isConnected()) {
|
||||||
ApplicationDependencies.getSignalCallManager().groupApproveSafetyChange(changedRecipients);
|
ApplicationDependencies.getSignalCallManager().groupApproveSafetyChange(changedRecipients);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 Signal Messenger, LLC
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.thoughtcrime.securesms.components.webrtc
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.database.identity.IdentityRecordList
|
||||||
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||||
|
import org.thoughtcrime.securesms.jobs.NullMessageSendJob
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In-Memory Cache that keeps track of whom we've sent NullMessages to. This is
|
||||||
|
* something that really only needs to happen once so that profile information is
|
||||||
|
* displayed correctly, so we maintain an application process scoped cache.
|
||||||
|
*/
|
||||||
|
object CallLinkNullMessageSender {
|
||||||
|
private val cache = hashSetOf<RecipientId>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked after pressing "Join" or "Continue" on the safety number change dialog before
|
||||||
|
* or during a call.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun onSendAnyway(recipientIds: Set<RecipientId>) {
|
||||||
|
val toSendMessagesTo: Set<RecipientId> = recipientIds - cache
|
||||||
|
cache += recipientIds
|
||||||
|
|
||||||
|
val jobs: List<NullMessageSendJob> = toSendMessagesTo.map { NullMessageSendJob(it) }
|
||||||
|
ApplicationDependencies.getJobManager().addAll(jobs)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the set of recipients, for each unblocked recipient we don't distrust, send a NullMessage
|
||||||
|
*/
|
||||||
|
fun onRecipientsUpdated(recipients: Set<Recipient>) {
|
||||||
|
val nonBlockedRecipients: List<Recipient> = recipients.filterNot { it.isBlocked }
|
||||||
|
|
||||||
|
val identityRecords: IdentityRecordList = ApplicationDependencies
|
||||||
|
.getProtocolStore()
|
||||||
|
.aci()
|
||||||
|
.identities()
|
||||||
|
.getIdentityRecords(nonBlockedRecipients)
|
||||||
|
|
||||||
|
val untrustedAndUnverifiedRecipients = if (identityRecords.isUntrusted(false) || identityRecords.isUnverified(false)) {
|
||||||
|
(identityRecords.untrustedRecipients + identityRecords.unverifiedRecipients).toSet()
|
||||||
|
} else {
|
||||||
|
emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
|
val trustedRecipients: Set<RecipientId> = (nonBlockedRecipients - untrustedAndUnverifiedRecipients).map { it.id }.toSet()
|
||||||
|
onSendAnyway(trustedRecipients)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import org.signal.core.util.logging.Log
|
|||||||
import org.signal.ringrtc.CallException
|
import org.signal.ringrtc.CallException
|
||||||
import org.signal.ringrtc.GroupCall
|
import org.signal.ringrtc.GroupCall
|
||||||
import org.signal.ringrtc.PeekInfo
|
import org.signal.ringrtc.PeekInfo
|
||||||
|
import org.thoughtcrime.securesms.components.webrtc.CallLinkNullMessageSender
|
||||||
import org.thoughtcrime.securesms.database.CallLinkTable
|
import org.thoughtcrime.securesms.database.CallLinkTable
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||||
import org.thoughtcrime.securesms.events.CallParticipant
|
import org.thoughtcrime.securesms.events.CallParticipant
|
||||||
@@ -54,6 +55,8 @@ class CallLinkConnectedActionProcessor(
|
|||||||
Log.i(tag, "Updating pending list with ${peekInfo.pendingUsers.size} entries.")
|
Log.i(tag, "Updating pending list with ${peekInfo.pendingUsers.size} entries.")
|
||||||
val pendingParticipants: List<Recipient> = peekInfo.pendingUsers.map { Recipient.externalPush(ServiceId.ACI.from(it)) }
|
val pendingParticipants: List<Recipient> = peekInfo.pendingUsers.map { Recipient.externalPush(ServiceId.ACI.from(it)) }
|
||||||
|
|
||||||
|
CallLinkNullMessageSender.onRecipientsUpdated(superState.callInfoState.remoteCallParticipants.map { it.recipient }.toSet())
|
||||||
|
|
||||||
return superState.builder()
|
return superState.builder()
|
||||||
.changeCallInfoState()
|
.changeCallInfoState()
|
||||||
.setCallLinkPendingParticipants(pendingParticipants)
|
.setCallLinkPendingParticipants(pendingParticipants)
|
||||||
|
|||||||
Reference in New Issue
Block a user