Skip to content

Commit

Permalink
Ensure no typing indicators can be sent to self or blocked recipients.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal committed Feb 24, 2021
1 parent 687192f commit da56c27
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -92,6 +92,12 @@ public void onRun() throws Exception {

if (recipient.isBlocked()) {
Log.w(TAG, "Not sending typing indicators to blocked recipients.");
return;
}

if (recipient.isSelf()) {
Log.w(TAG, "Not sending typing indicators to self.");
return;
}

List<Recipient> recipients = Collections.singletonList(recipient);
Expand All @@ -104,13 +110,19 @@ public void onRun() throws Exception {

recipients = RecipientUtil.getEligibleForSending(Stream.of(recipients)
.map(Recipient::resolve)
.filter(r -> !r.isBlocked())
.toList());

SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
List<SignalServiceAddress> addresses = RecipientUtil.toSignalServiceAddressesFromResolved(context, recipients);
List<Optional<UnidentifiedAccessPair>> unidentifiedAccess = UnidentifiedAccessUtil.getAccessFor(context, recipients);
SignalServiceTypingMessage typingMessage = new SignalServiceTypingMessage(typing ? Action.STARTED : Action.STOPPED, System.currentTimeMillis(), groupId);

if (addresses.isEmpty()) {
Log.w(TAG, "No one to send typing indicators to");
return;
}

if (isCanceled()) {
Log.w(TAG, "Canceled before send!");
return;
Expand Down

0 comments on commit da56c27

Please sign in to comment.