diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 1f473a117c..5f60da222b 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -1189,17 +1189,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } private boolean isSelfConversation() { - try { - if (!TextSecurePreferences.isPushRegistered(this)) return false; - if (!recipients.isSingleRecipient()) return false; - if (recipients.getPrimaryRecipient().isGroupRecipient()) return false; + if (!TextSecurePreferences.isPushRegistered(this)) return false; + if (!recipients.isSingleRecipient()) return false; + if (recipients.getPrimaryRecipient().isGroupRecipient()) return false; - return Util.canonicalizeNumber(this, recipients.getPrimaryRecipient().getNumber()) - .equals(TextSecurePreferences.getLocalNumber(this)); - } catch (InvalidNumberException e) { - Log.w(TAG, e); - return false; - } + return Util.isOwnNumber(this, recipients.getPrimaryRecipient().getNumber()); } private boolean isGroupConversation() { diff --git a/src/org/thoughtcrime/securesms/sms/MessageSender.java b/src/org/thoughtcrime/securesms/sms/MessageSender.java index 28f59b0fe8..8fb91178ee 100644 --- a/src/org/thoughtcrime/securesms/sms/MessageSender.java +++ b/src/org/thoughtcrime/securesms/sms/MessageSender.java @@ -255,25 +255,19 @@ public class MessageSender { } private static boolean isSelfSend(Context context, Recipients recipients) { - try { - if (!TextSecurePreferences.isPushRegistered(context)) { - return false; - } - - if (!recipients.isSingleRecipient()) { - return false; - } - - if (recipients.isGroupRecipient()) { - return false; - } - - String e164number = Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber()); - return TextSecurePreferences.getLocalNumber(context).equals(e164number); - } catch (InvalidNumberException e) { - Log.w("MessageSender", e); + if (!TextSecurePreferences.isPushRegistered(context)) { return false; } + + if (!recipients.isSingleRecipient()) { + return false; + } + + if (recipients.isGroupRecipient()) { + return false; + } + + return Util.isOwnNumber(context, recipients.getPrimaryRecipient().getNumber()); } private static boolean isPushDestination(Context context, String destination) { diff --git a/src/org/thoughtcrime/securesms/util/DirectoryHelper.java b/src/org/thoughtcrime/securesms/util/DirectoryHelper.java index f32a9fcaca..f2e656e71b 100644 --- a/src/org/thoughtcrime/securesms/util/DirectoryHelper.java +++ b/src/org/thoughtcrime/securesms/util/DirectoryHelper.java @@ -216,7 +216,7 @@ public class DirectoryHelper { if (!TextSecurePreferences.isNewContactsNotificationEnabled(context)) return; for (String newUser : newUsers) { - if (!SessionUtil.hasSession(context, masterSecret, newUser)) { + if (!SessionUtil.hasSession(context, masterSecret, newUser) && !Util.isOwnNumber(context, newUser)) { IncomingJoinedMessage message = new IncomingJoinedMessage(newUser); Pair smsAndThreadId = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message); diff --git a/src/org/thoughtcrime/securesms/util/Util.java b/src/org/thoughtcrime/securesms/util/Util.java index f0c40af315..fe2bb39c5b 100644 --- a/src/org/thoughtcrime/securesms/util/Util.java +++ b/src/org/thoughtcrime/securesms/util/Util.java @@ -184,6 +184,16 @@ public class Util { else return canonicalizeNumber(context, number); } + public static boolean isOwnNumber(Context context, String number) { + try { + String e164number = canonicalizeNumber(context, number); + return TextSecurePreferences.getLocalNumber(context).equals(e164number); + } catch (InvalidNumberException e) { + Log.w(TAG, e); + } + return false; + } + public static byte[] readFully(InputStream in) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte[] buffer = new byte[4096];