Add Small Group Ringing support.

This commit is contained in:
Cody Henthorne
2021-08-24 10:18:39 -04:00
committed by Alex Hart
parent 5787a5f68a
commit db7272730e
39 changed files with 1597 additions and 609 deletions

View File

@@ -34,6 +34,7 @@ import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
import org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage;
import org.whispersystems.signalservice.api.push.DistributionId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.internal.push.exceptions.InvalidUnidentifiedAccessHeaderException;
@@ -122,6 +123,22 @@ public final class GroupSendUtil {
return sendMessage(context, groupId, allTargets, false, new TypingSendOperation(message), cancelationSignal);
}
/**
* Handles all of the logic of sending to a group. Will do sender key sends and legacy 1:1 sends as-needed, and give you back a list of
* {@link SendMessageResult}s just like we're used to.
*
* @param groupId The groupId of the group you're sending to, or null if you're sending to a collection of recipients not joined by a group.
*/
@WorkerThread
public static List<SendMessageResult> sendCallMessage(@NonNull Context context,
@Nullable GroupId.V2 groupId,
@NonNull List<Recipient> allTargets,
@NonNull SignalServiceCallMessage message)
throws IOException, UntrustedIdentityException
{
return sendMessage(context, groupId, allTargets, false, new CallSendOperation(message), null);
}
/**
* Handles all of the logic of sending to a group. Will do sender key sends and legacy 1:1 sends as-needed, and give you back a list of
* {@link SendMessageResult}s just like we're used to.
@@ -434,6 +451,58 @@ public final class GroupSendUtil {
}
}
private static class CallSendOperation implements SendOperation {
private final SignalServiceCallMessage message;
private CallSendOperation(@NonNull SignalServiceCallMessage message) {
this.message = message;
}
@Override
public @NonNull List<SendMessageResult> sendWithSenderKey(@NonNull SignalServiceMessageSender messageSender,
@NonNull DistributionId distributionId,
@NonNull List<SignalServiceAddress> targets,
@NonNull List<UnidentifiedAccess> access,
boolean isRecipientUpdate)
throws NoSessionException, UntrustedIdentityException, InvalidKeyException, IOException
{
return messageSender.sendCallMessage(distributionId, targets, access, message);
}
@Override
public @NonNull List<SendMessageResult> sendLegacy(@NonNull SignalServiceMessageSender messageSender,
@NonNull List<SignalServiceAddress> targets,
@NonNull List<Optional<UnidentifiedAccessPair>> access,
boolean isRecipientUpdate,
@Nullable PartialSendCompleteListener partialListener,
@Nullable CancelationSignal cancelationSignal)
throws IOException
{
return messageSender.sendCallMessage(targets, access, message);
}
@Override
public @NonNull ContentHint getContentHint() {
return ContentHint.IMPLICIT;
}
@Override
public long getSentTimestamp() {
return message.getTimestamp().get();
}
@Override
public boolean shouldIncludeInMessageLog() {
return false;
}
@Override
public @NonNull MessageId getRelatedMessageId() {
throw new UnsupportedOperationException();
}
}
/**
* Little utility wrapper that lets us get the various different slices of recipient models that we need for different methods.
*/