mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 19:48:33 +00:00
Do not attempt to retrieve a profile when it is not a number.
Fixes #8855
This commit is contained in:
parent
ae784db80d
commit
42a5504f0d
@ -33,7 +33,6 @@ import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
|
|||||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -50,7 +49,7 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
@Inject SignalServiceMessageReceiver receiver;
|
@Inject SignalServiceMessageReceiver receiver;
|
||||||
|
|
||||||
private Recipient recipient;
|
private final Recipient recipient;
|
||||||
|
|
||||||
public RetrieveProfileJob(@NonNull Recipient recipient) {
|
public RetrieveProfileJob(@NonNull Recipient recipient) {
|
||||||
this(new Job.Parameters.Builder()
|
this(new Job.Parameters.Builder()
|
||||||
@ -76,13 +75,9 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun() throws IOException, InvalidKeyException {
|
public void onRun() throws IOException {
|
||||||
try {
|
if (recipient.isGroupRecipient()) handleGroupRecipient(recipient);
|
||||||
if (recipient.isGroupRecipient()) handleGroupRecipient(recipient);
|
else handleIndividualRecipient(recipient);
|
||||||
else handleIndividualRecipient(recipient);
|
|
||||||
} catch (InvalidNumberException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -93,9 +88,12 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||||||
@Override
|
@Override
|
||||||
public void onCanceled() {}
|
public void onCanceled() {}
|
||||||
|
|
||||||
private void handleIndividualRecipient(Recipient recipient)
|
private void handleIndividualRecipient(Recipient recipient) throws IOException {
|
||||||
throws IOException, InvalidKeyException, InvalidNumberException
|
if (recipient.getAddress().isPhone()) handlePhoneNumberRecipient(recipient);
|
||||||
{
|
else Log.w(TAG, "Skipping fetching profile of non-phone recipient");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handlePhoneNumberRecipient(Recipient recipient) throws IOException {
|
||||||
String number = recipient.getAddress().toPhoneString();
|
String number = recipient.getAddress().toPhoneString();
|
||||||
Optional<UnidentifiedAccess> unidentifiedAccess = getUnidentifiedAccess(recipient);
|
Optional<UnidentifiedAccess> unidentifiedAccess = getUnidentifiedAccess(recipient);
|
||||||
|
|
||||||
@ -117,9 +115,7 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||||||
setUnidentifiedAccessMode(recipient, profile.getUnidentifiedAccess(), profile.isUnrestrictedUnidentifiedAccess());
|
setUnidentifiedAccessMode(recipient, profile.getUnidentifiedAccess(), profile.isUnrestrictedUnidentifiedAccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleGroupRecipient(Recipient group)
|
private void handleGroupRecipient(Recipient group) throws IOException {
|
||||||
throws IOException, InvalidKeyException, InvalidNumberException
|
|
||||||
{
|
|
||||||
List<Recipient> recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(group.getAddress().toGroupString(), false);
|
List<Recipient> recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(group.getAddress().toGroupString(), false);
|
||||||
|
|
||||||
for (Recipient recipient : recipients) {
|
for (Recipient recipient : recipients) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user