Exclude the user's own number from notifyNewUsers

Closes #5229
// FREEBIE
This commit is contained in:
haffenloher 2016-02-14 14:58:39 +01:00 committed by Moxie Marlinspike
parent 156c5c6e09
commit 72064d8827
4 changed files with 26 additions and 28 deletions

View File

@ -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;
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() {

View File

@ -255,7 +255,6 @@ public class MessageSender {
}
private static boolean isSelfSend(Context context, Recipients recipients) {
try {
if (!TextSecurePreferences.isPushRegistered(context)) {
return false;
}
@ -268,12 +267,7 @@ public class MessageSender {
return false;
}
String e164number = Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber());
return TextSecurePreferences.getLocalNumber(context).equals(e164number);
} catch (InvalidNumberException e) {
Log.w("MessageSender", e);
return false;
}
return Util.isOwnNumber(context, recipients.getPrimaryRecipient().getNumber());
}
private static boolean isPushDestination(Context context, String destination) {

View File

@ -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<Long, Long> smsAndThreadId = DatabaseFactory.getSmsDatabase(context).insertMessageInbox(message);

View File

@ -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];