Skip to content

Commit

Permalink
Filter out packages based on MustOwnAppToPurchase property
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed May 29, 2024
1 parent c4c50b0 commit e1d3048
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions FreePackages/Data/FilterablePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal sealed class FilterablePackage {
internal ulong ExpiryTime;
internal ulong StartTime;
internal uint DontGrantIfAppIDOwned;
internal uint MustOwnAppToPurchase;
internal List<string>? RestrictedCountries;
internal bool OnlyAllowRestrictedCountries;
internal List<string>? PurchaseRestrictedCountries;
Expand All @@ -38,6 +39,7 @@ internal FilterablePackage(uint id, KeyValue kv, bool isNew) {
ExpiryTime = kv["extended"]["expirytime"].AsUnsignedLong();
StartTime = kv["extended"]["starttime"].AsUnsignedLong();
DontGrantIfAppIDOwned = kv["extended"]["dontgrantifappidowned"].AsUnsignedInteger();
MustOwnAppToPurchase = kv["extended"]["mustownapptopurchase"].AsUnsignedInteger();
RestrictedCountries = kv["extended"]["restrictedcountries"].AsString()?.ToUpper().Split(" ").ToList();
OnlyAllowRestrictedCountries = kv["extended"]["onlyallowrestrictedcountries"].AsBoolean();
PurchaseRestrictedCountries = kv["extended"]["purchaserestrictedcountries"].AsString()?.ToUpper().Split(" ").ToList();
Expand Down
5 changes: 5 additions & 0 deletions FreePackages/Handlers/PackageFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ internal bool IsRedeemablePackage(FilterablePackage package) {
}

if (package.DontGrantIfAppIDOwned > 0 && OwnedAppIDs.Contains(package.DontGrantIfAppIDOwned)) {
// Owns an app that blocks activation
return false;
}

if (package.MustOwnAppToPurchase > 0 && !OwnedAppIDs.Contains(package.MustOwnAppToPurchase)) {
// Don't own required app
return false;
}
Expand Down

0 comments on commit e1d3048

Please sign in to comment.