Ignore inbound SMS/MMS from yourself.
This commit is contained in:
parent
348b6e9742
commit
c7a345eb0b
2 changed files with 21 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue