Ignore inbound SMS/MMS from yourself.

fork-5.53.8
Greyson Parrelli 2022-03-29 18:29:46 -04:00
rodzic 348b6e9742
commit c7a345eb0b
2 zmienionych plików z 21 dodań i 6 usunięć

Wyświetl plik

@ -71,7 +71,11 @@ public class MmsReceiveJob extends BaseJob {
Log.w(TAG, e);
}
if (isNotification(pdu) && !isBlocked(pdu)) {
if (isNotification(pdu) && isBlocked(pdu)) {
Log.w(TAG, "Received an MMS from a blocked user. Ignoring.");
} else if (isNotification(pdu) && isSelf(pdu)) {
Log.w(TAG, "Received an MMS from ourselves! Ignoring.");
} else if (isNotification(pdu)) {
MessageDatabase database = SignalDatabase.mms();
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox((NotificationInd)pdu, subscriptionId);
@ -80,8 +84,8 @@ public class MmsReceiveJob extends BaseJob {
ApplicationDependencies.getJobManager().add(new MmsDownloadJob(messageAndThreadId.first(),
messageAndThreadId.second(),
true));
} else if (isNotification(pdu)) {
Log.w(TAG, "*** Received blocked MMS, ignoring...");
} else {
Log.w(TAG, "Unable to process MMS.");
}
}
@ -104,6 +108,15 @@ public class MmsReceiveJob extends BaseJob {
return false;
}
private boolean isSelf(GenericPdu pdu) {
if (pdu.getFrom() != null && pdu.getFrom().getTextString() != null) {
Recipient recipients = Recipient.external(context, Util.toIsoString(pdu.getFrom().getTextString()));
return recipients.isSelf();
}
return false;
}
private boolean isNotification(GenericPdu pdu) {
return pdu != null && pdu.getMessageType() == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
}

Wyświetl plik

@ -117,16 +117,18 @@ public class SmsReceiveJob extends BaseJob {
}
}
if (message.isPresent() && !isBlocked(message.get())) {
if (message.isPresent() && SignalStore.account().getE164() != null && message.get().getSender().equals(Recipient.self().getId())) {
Log.w(TAG, "Received an SMS from ourselves! Ignoring.");
} else if (message.isPresent() && !isBlocked(message.get())) {
Optional<InsertResult> insertResult = storeMessage(message.get());
if (insertResult.isPresent()) {
ApplicationDependencies.getMessageNotifier().updateNotification(context, insertResult.get().getThreadId());
}
} else if (message.isPresent()) {
Log.w(TAG, "*** Received blocked SMS, ignoring...");
Log.w(TAG, "Received an SMS from a blocked user. Ignoring.");
} else {
Log.w(TAG, "*** Failed to assemble message fragments!");
Log.w(TAG, "Failed to assemble message fragments!");
}
}