Check account age for donation eligibility
This commit is contained in:
parent
b5aa1a4598
commit
d0d899c73d
|
@ -33,6 +33,8 @@ import org.joinmastodon.android.model.TimelineMarkers;
|
||||||
import org.joinmastodon.android.model.Token;
|
import org.joinmastodon.android.model.Token;
|
||||||
import org.joinmastodon.android.utils.ObjectIdComparator;
|
import org.joinmastodon.android.utils.ObjectIdComparator;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -43,6 +45,7 @@ import me.grishka.appkit.api.ErrorResponse;
|
||||||
|
|
||||||
public class AccountSession{
|
public class AccountSession{
|
||||||
private static final String TAG="AccountSession";
|
private static final String TAG="AccountSession";
|
||||||
|
private static final int MIN_DAYS_ACCOUNT_AGE_FOR_DONATIONS=28;
|
||||||
|
|
||||||
public Token token;
|
public Token token;
|
||||||
public Account self;
|
public Account self;
|
||||||
|
@ -277,7 +280,7 @@ public class AccountSession{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEligibleForDonations(){
|
public boolean isEligibleForDonations(){
|
||||||
return "mastodon.social".equalsIgnoreCase(domain) || "mastodon.online".equalsIgnoreCase(domain);
|
return ("mastodon.social".equalsIgnoreCase(domain) || "mastodon.online".equalsIgnoreCase(domain)) && self.createdAt.isBefore(Instant.now().minus(MIN_DAYS_ACCOUNT_AGE_FOR_DONATIONS, ChronoUnit.DAYS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDonationSeed(){
|
public int getDonationSeed(){
|
||||||
|
|
Loading…
Reference in New Issue