Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
chore: Remove unnecessary consumer parameter (#591)
Browse files Browse the repository at this point in the history
The query parameter was introduced for future use. It turns out that it is unnecessary and can be removed therefor.
  • Loading branch information
oSumAtrIX authored Mar 25, 2024
1 parent 32a14ef commit bed8f9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Locale;
import java.util.UUID;

import static android.text.Html.FROM_HTML_MODE_COMPACT;
import static app.revanced.integrations.shared.StringRef.str;
import static app.revanced.integrations.youtube.patches.announcements.requests.AnnouncementsRoutes.GET_LATEST_ANNOUNCEMENT;

@SuppressWarnings("unused")
public final class AnnouncementsPatch {
private final static String CONSUMER = getOrSetConsumer();

private AnnouncementsPatch() {
}

Expand All @@ -41,7 +38,7 @@ public static void showAnnouncement(final Activity context) {
Utils.runOnBackgroundThread(() -> {
try {
HttpURLConnection connection = AnnouncementsRoutes.getAnnouncementsConnectionFromRoute(
GET_LATEST_ANNOUNCEMENT, CONSUMER, Locale.getDefault().toLanguageTag());
GET_LATEST_ANNOUNCEMENT, Locale.getDefault().toLanguageTag());

Logger.printDebug(() -> "Get latest announcement route connection url: " + connection.getURL());

Expand Down Expand Up @@ -139,15 +136,6 @@ public static void showAnnouncement(final Activity context) {
});
}

private static String getOrSetConsumer() {
final var consumer = Settings.ANNOUNCEMENT_CONSUMER.get();
if (!consumer.isEmpty()) return consumer;

final var uuid = UUID.randomUUID().toString();
Settings.ANNOUNCEMENT_CONSUMER.save(uuid);
return uuid;
}

// TODO: Use better icons.
private enum Level {
INFO(android.R.drawable.ic_dialog_info),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class AnnouncementsRoutes {
/**
* 'language' parameter is IETF format (for USA it would be 'en-us').
*/
public static final Route GET_LATEST_ANNOUNCEMENT = new Route(GET, "/announcements/youtube/latest?consumer={consumer}&language={language}");
public static final Route GET_LATEST_ANNOUNCEMENT = new Route(GET, "/announcements/youtube/latest?language={language}");

private AnnouncementsRoutes() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public class Settings extends BaseSettings {
public static final BooleanSetting SPOOF_DEVICE_DIMENSIONS = new BooleanSetting("revanced_spoof_device_dimensions", FALSE, true);
public static final BooleanSetting BYPASS_URL_REDIRECTS = new BooleanSetting("revanced_bypass_url_redirects", TRUE);
public static final BooleanSetting ANNOUNCEMENTS = new BooleanSetting("revanced_announcements", TRUE);
public static final StringSetting ANNOUNCEMENT_CONSUMER = new StringSetting("revanced_announcement_consumer", "", false, false);
@Deprecated
public static final StringSetting DEPRECATED_ANNOUNCEMENT_LAST_HASH = new StringSetting("revanced_announcement_last_hash", "");
public static final IntegerSetting ANNOUNCEMENT_LAST_ID = new IntegerSetting("revanced_announcement_last_id", -1);
Expand Down Expand Up @@ -346,6 +345,10 @@ public class Settings extends BaseSettings {
}


// Remove any previously saved announcement consumer (a random generated string).
Setting.preferences.saveString("revanced_announcement_consumer", null);


// endregion
}
}

0 comments on commit bed8f9f

Please sign in to comment.