fix(Spotify): Remove ads sections from home (#4722)

Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
Nuckyz
2025-04-04 09:32:40 -03:00
committed by GitHub
parent eaee621831
commit 0b9a5e7f89
5 changed files with 130 additions and 25 deletions

View File

@ -4,6 +4,7 @@ import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import com.spotify.remoteconfig.internal.AccountAttribute;
import com.spotify.home.evopage.homeapi.proto.Section;
import java.util.List;
import java.util.Map;
@ -69,8 +70,13 @@ public final class UnlockPremiumPatch {
new OverrideAttribute("tablet-free", FALSE, false)
);
private static final List<Integer> REMOVED_HOME_SECTIONS = List.of(
Section.VIDEO_BRAND_AD_FIELD_NUMBER,
Section.IMAGE_BRAND_AD_FIELD_NUMBER
);
/**
* Injection point.
* Override attributes injection point.
*/
public static void overrideAttribute(Map<String, AccountAttribute> attributes) {
try {
@ -78,7 +84,7 @@ public final class UnlockPremiumPatch {
var attribute = attributes.get(override.key);
if (attribute == null) {
if (override.isExpected) {
Logger.printException(() -> "''" + override.key + "' expected but not found");
Logger.printException(() -> "'" + override.key + "' expected but not found");
}
} else {
attribute.value_ = override.overrideValue;
@ -88,4 +94,15 @@ public final class UnlockPremiumPatch {
Logger.printException(() -> "overrideAttribute failure", ex);
}
}
/**
* Remove ads sections from home injection point.
*/
public static void removeHomeSections(List<Section> sections) {
try {
sections.removeIf(section -> REMOVED_HOME_SECTIONS.contains(section.featureTypeCase_));
} catch (Exception ex) {
Logger.printException(() -> "Remove home sections failure", ex);
}
}
}

View File

@ -0,0 +1,7 @@
package com.spotify.home.evopage.homeapi.proto;
public final class Section {
public static final int VIDEO_BRAND_AD_FIELD_NUMBER = 20;
public static final int IMAGE_BRAND_AD_FIELD_NUMBER = 21;
public int featureTypeCase_;
}