Show blocked users as 'skipped' when sending to curated story list.

This commit is contained in:
Greyson Parrelli
2023-03-17 09:54:20 -04:00
parent 17fc0dc0a1
commit 49a814abef
2 changed files with 14 additions and 4 deletions

View File

@@ -164,6 +164,7 @@ public final class PushDistributionListSendJob extends PushSendJob {
log(TAG, String.valueOf(message.getSentTimeMillis()), "Sending message: " + messageId + ", Recipient: " + message.getRecipient().getId() + ", Attachments: " + buildAttachmentString(message.getAttachments()));
List<Recipient> targets;
List<RecipientId> skipped = Collections.emptyList();
if (Util.hasItems(filterRecipientIds)) {
targets = new ArrayList<>(filterRecipientIds.size() + existingNetworkFailures.size());
@@ -172,13 +173,15 @@ public final class PushDistributionListSendJob extends PushSendJob {
} else if (!existingNetworkFailures.isEmpty()) {
targets = Stream.of(existingNetworkFailures).map(nf -> nf.getRecipientId(context)).distinct().map(Recipient::resolved).toList();
} else {
targets = Stream.of(Stories.getRecipientsToSendTo(messageId, message.getSentTimeMillis(), message.getStoryType().isStoryWithReplies())).distinctBy(Recipient::getId).toList();
Stories.SendData data = Stories.getRecipientsToSendTo(messageId, message.getSentTimeMillis(), message.getStoryType().isStoryWithReplies());
targets = data.getTargets();
skipped = data.getSkipped();
}
List<SendMessageResult> results = deliver(message, targets);
Log.i(TAG, JobLogger.format(this, "Finished send."));
PushGroupSendJob.processGroupMessageResults(context, messageId, -1, null, message, results, targets, Collections.emptyList(), existingNetworkFailures, existingIdentityMismatches);
PushGroupSendJob.processGroupMessageResults(context, messageId, -1, null, message, results, targets, skipped, existingNetworkFailures, existingIdentityMismatches);
} catch (UntrustedIdentityException | UndeliverableMessageException e) {
warn(TAG, String.valueOf(message.getSentTimeMillis()), e);

View File

@@ -89,10 +89,12 @@ object Stories {
}
@JvmStatic
fun getRecipientsToSendTo(messageId: Long, sentTimestamp: Long, allowsReplies: Boolean): List<Recipient> {
fun getRecipientsToSendTo(messageId: Long, sentTimestamp: Long, allowsReplies: Boolean): SendData {
val recipientIds: List<RecipientId> = SignalDatabase.storySends.getRecipientsToSendTo(messageId, sentTimestamp, allowsReplies)
val targets: List<Recipient> = RecipientUtil.getEligibleForSending(recipientIds.map(Recipient::resolved)).distinctBy { it.id }
val skipped: List<RecipientId> = (recipientIds.toSet() - targets.map { it.id }.toSet()).toList()
return RecipientUtil.getEligibleForSending(recipientIds.map(Recipient::resolved))
return SendData(targets, skipped)
}
@WorkerThread
@@ -398,4 +400,9 @@ object Stories {
)
}
}
data class SendData(
val targets: List<Recipient>,
val skipped: List<RecipientId>
)
}