kopia lustrzana https://github.com/ryukoposting/Signal-Android
Allow retries for redemption from server failure. Add internal preference to enqueue job.
rodzic
0bac08dcc4
commit
00a8565e91
|
@ -24,8 +24,11 @@ import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob
|
||||||
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
||||||
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob
|
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob
|
||||||
import org.thoughtcrime.securesms.jobs.StorageForcePushJob
|
import org.thoughtcrime.securesms.jobs.StorageForcePushJob
|
||||||
|
import org.thoughtcrime.securesms.jobs.SubscriptionReceiptRequestResponseJob
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
import org.thoughtcrime.securesms.payments.DataExportUtil
|
import org.thoughtcrime.securesms.payments.DataExportUtil
|
||||||
import org.thoughtcrime.securesms.util.ConversationUtil
|
import org.thoughtcrime.securesms.util.ConversationUtil
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||||
import org.thoughtcrime.securesms.util.concurrent.SimpleTask
|
import org.thoughtcrime.securesms.util.concurrent.SimpleTask
|
||||||
|
|
||||||
class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__internal_preferences) {
|
class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__internal_preferences) {
|
||||||
|
@ -317,6 +320,17 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FeatureFlags.donorBadges() && SignalStore.donationsValues().getSubscriber() != null) {
|
||||||
|
sectionHeaderPref(R.string.preferences__internal_badges)
|
||||||
|
|
||||||
|
clickPref(
|
||||||
|
title = DSLSettingsText.from(R.string.preferences__internal_badges_enqueue_redemption),
|
||||||
|
onClick = {
|
||||||
|
enqueueSubscriptionRedemption()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,4 +413,8 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||||
LocalMetricsDatabase.getInstance(ApplicationDependencies.getApplication()).clear()
|
LocalMetricsDatabase.getInstance(ApplicationDependencies.getApplication()).clear()
|
||||||
Toast.makeText(context, "Cleared all local metrics state.", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "Cleared all local metrics state.", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun enqueueSubscriptionRedemption() {
|
||||||
|
SubscriptionReceiptRequestResponseJob.enqueueSubscriptionContinuation()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,8 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
||||||
if (response.getStatus() == 204) {
|
if (response.getStatus() == 204) {
|
||||||
Log.w(TAG, "User does not have receipts available to exchange. Exiting.", response.getApplicationError().get());
|
Log.w(TAG, "User does not have receipts available to exchange. Exiting.", response.getApplicationError().get());
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Encountered a permanent failure: " + response.getStatus(), response.getApplicationError().get());
|
Log.w(TAG, "Encountered a server failure: " + response.getStatus(), response.getApplicationError().get());
|
||||||
throw new Exception(response.getApplicationError().get());
|
throw new RetryableException();
|
||||||
}
|
}
|
||||||
} else if (response.getResult().isPresent()) {
|
} else if (response.getResult().isPresent()) {
|
||||||
ReceiptCredential receiptCredential = getReceiptCredential(response.getResult().get());
|
ReceiptCredential receiptCredential = getReceiptCredential(response.getResult().get());
|
||||||
|
|
|
@ -140,8 +140,8 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
|
||||||
if (response.getStatus() == 204) {
|
if (response.getStatus() == 204) {
|
||||||
Log.w(TAG, "User does not have receipts available to exchange. Exiting.", response.getApplicationError().get());
|
Log.w(TAG, "User does not have receipts available to exchange. Exiting.", response.getApplicationError().get());
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Encountered a permanent failure: " + response.getStatus(), response.getApplicationError().get());
|
Log.w(TAG, "Encountered a server failure response: " + response.getStatus(), response.getApplicationError().get());
|
||||||
throw new Exception(response.getApplicationError().get());
|
throw new RetryableException();
|
||||||
}
|
}
|
||||||
} else if (response.getResult().isPresent()) {
|
} else if (response.getResult().isPresent()) {
|
||||||
ReceiptCredential receiptCredential = getReceiptCredential(response.getResult().get());
|
ReceiptCredential receiptCredential = getReceiptCredential(response.getResult().get());
|
||||||
|
@ -215,6 +215,12 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
|
||||||
boolean isExpirationInTheFuture = receiptCredential.getReceiptExpirationTime() > now;
|
boolean isExpirationInTheFuture = receiptCredential.getReceiptExpirationTime() > now;
|
||||||
boolean isExpirationWithinAMonth = receiptCredential.getReceiptExpirationTime() < monthFromNow;
|
boolean isExpirationWithinAMonth = receiptCredential.getReceiptExpirationTime() < monthFromNow;
|
||||||
|
|
||||||
|
Log.d(TAG, "Credential validation: isSameLevel(" + isSameLevel +
|
||||||
|
") isExpirationAfterSub(" + isExpirationAfterSub +
|
||||||
|
") isExpiration86400(" + isExpiration86400 +
|
||||||
|
") isExpirationInTheFuture(" + isExpirationInTheFuture +
|
||||||
|
") isExpirationWithinAMonth(" + isExpirationWithinAMonth + ")");
|
||||||
|
|
||||||
return isSameLevel && isExpirationAfterSub && isExpiration86400 && isExpirationInTheFuture && isExpirationWithinAMonth;
|
return isSameLevel && isExpirationAfterSub && isExpiration86400 && isExpirationInTheFuture && isExpirationWithinAMonth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2601,6 +2601,9 @@
|
||||||
<string name="preferences__internal_calling" translatable="false">Group call server</string>
|
<string name="preferences__internal_calling" translatable="false">Group call server</string>
|
||||||
<string name="preferences__internal_calling_default" translatable="false">Default</string>
|
<string name="preferences__internal_calling_default" translatable="false">Default</string>
|
||||||
<string name="preferences__internal_calling_s_server" translatable="false">%1$s server</string>
|
<string name="preferences__internal_calling_s_server" translatable="false">%1$s server</string>
|
||||||
|
<string name="preferences__internal_badges" translatable="false">Badges</string>
|
||||||
|
<string name="preferences__internal_badges_enqueue_redemption" translatable="false">Enqueue redemption.</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Payments -->
|
<!-- Payments -->
|
||||||
<string name="PaymentsActivityFragment__all_activity">All activity</string>
|
<string name="PaymentsActivityFragment__all_activity">All activity</string>
|
||||||
|
|
Ładowanie…
Reference in New Issue