mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 08:58:45 +00:00
Add option that allows disabling MMS fallback with TS users.
// FREEBIE Closes #1444
This commit is contained in:
@@ -47,7 +47,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
private final long messageId;
|
||||
|
||||
public PushMediaSendJob(Context context, long messageId, String destination) {
|
||||
super(context, constructParameters(context, destination));
|
||||
super(context, constructParameters(context, destination, true));
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
TextSecureMessageSender messageSender = messageSenderFactory.create(masterSecret);
|
||||
String destination = message.getTo()[0].getString();
|
||||
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination);
|
||||
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination, true);
|
||||
|
||||
try {
|
||||
Recipients recipients = RecipientFactory.getRecipientsFromString(context, destination, false);
|
||||
@@ -132,7 +132,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
{
|
||||
try {
|
||||
Recipient recipient = RecipientFactory.getRecipientsFromString(context, destination, false).getPrimaryRecipient();
|
||||
boolean isSmsFallbackApprovalRequired = isSmsFallbackApprovalRequired(destination);
|
||||
boolean isSmsFallbackApprovalRequired = isSmsFallbackApprovalRequired(destination, true);
|
||||
AxolotlStore axolotlStore = new TextSecureAxolotlStore(context, masterSecret);
|
||||
|
||||
if (!isSmsFallbackApprovalRequired) {
|
||||
|
||||
@@ -34,13 +34,13 @@ public abstract class PushSendJob extends MasterSecretJob {
|
||||
super(context, parameters);
|
||||
}
|
||||
|
||||
protected static JobParameters constructParameters(Context context, String destination) {
|
||||
protected static JobParameters constructParameters(Context context, String destination, boolean media) {
|
||||
JobParameters.Builder builder = JobParameters.newBuilder();
|
||||
builder.withPersistence();
|
||||
builder.withGroupId(destination);
|
||||
builder.withRequirement(new MasterSecretRequirement(context));
|
||||
|
||||
if (!isSmsFallbackSupported(context, destination)) {
|
||||
if (!isSmsFallbackSupported(context, destination, media)) {
|
||||
builder.withRequirement(new NetworkRequirement(context));
|
||||
builder.withRetryCount(5);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public abstract class PushSendJob extends MasterSecretJob {
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
protected static boolean isSmsFallbackSupported(Context context, String destination) {
|
||||
protected static boolean isSmsFallbackSupported(Context context, String destination, boolean media) {
|
||||
try {
|
||||
String e164number = Util.canonicalizeNumber(context, destination);
|
||||
|
||||
@@ -60,6 +60,10 @@ public abstract class PushSendJob extends MasterSecretJob {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (media && !TextSecurePreferences.isFallbackMmsEnabled(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TextSecureDirectory directory = TextSecureDirectory.getInstance(context);
|
||||
return directory.isSmsFallbackSupported(e164number);
|
||||
} catch (InvalidNumberException e) {
|
||||
@@ -74,8 +78,8 @@ public abstract class PushSendJob extends MasterSecretJob {
|
||||
return new PushAddress(recipient.getRecipientId(), e164number, 1, relay);
|
||||
}
|
||||
|
||||
protected boolean isSmsFallbackApprovalRequired(String destination) {
|
||||
return (isSmsFallbackSupported(context, destination) && TextSecurePreferences.isFallbackSmsAskRequired(context));
|
||||
protected boolean isSmsFallbackApprovalRequired(String destination, boolean media) {
|
||||
return (isSmsFallbackSupported(context, destination, media) && TextSecurePreferences.isFallbackSmsAskRequired(context));
|
||||
}
|
||||
|
||||
protected List<TextSecureAttachment> getAttachments(SendReq message) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
private final long messageId;
|
||||
|
||||
public PushTextSendJob(Context context, long messageId, String destination) {
|
||||
super(context, constructParameters(context, destination));
|
||||
super(context, constructParameters(context, destination, false));
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
throws UntrustedIdentityException, SecureFallbackApprovalException,
|
||||
InsecureFallbackApprovalException, RetryLaterException
|
||||
{
|
||||
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination);
|
||||
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination, false);
|
||||
|
||||
try {
|
||||
PushAddress address = getPushAddress(message.getIndividualRecipient());
|
||||
@@ -133,7 +133,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
throws SecureFallbackApprovalException, InsecureFallbackApprovalException
|
||||
{
|
||||
Recipient recipient = smsMessage.getIndividualRecipient();
|
||||
boolean isSmsFallbackApprovalRequired = isSmsFallbackApprovalRequired(destination);
|
||||
boolean isSmsFallbackApprovalRequired = isSmsFallbackApprovalRequired(destination, false);
|
||||
AxolotlStore axolotlStore = new TextSecureAxolotlStore(context, masterSecret);
|
||||
|
||||
if (!isSmsFallbackApprovalRequired) {
|
||||
|
||||
Reference in New Issue
Block a user