From b93c43e862d2355dee99bf453b1c6ab5394cba0a Mon Sep 17 00:00:00 2001 From: Pitchfork-and-Torch <297513015+Pitchfork-and-Torch@users.noreply.github.com> Date: Fri, 4 Sep 2026 16:15:02 -0400 Subject: [PATCH] Honor account country when applying geo media and legal takedown rules. --- visibility-filtering/rules/context.rs | 10 +++++++-- visibility-filtering/rules/golden_corpus.rs | 23 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/visibility-filtering/rules/context.rs b/visibility-filtering/rules/context.rs index 5b9b939a..e5155f49 100644 --- a/visibility-filtering/rules/context.rs +++ b/visibility-filtering/rules/context.rs @@ -259,7 +259,12 @@ impl TakedownPredicates<'_> { #[inline] fn in_viewer_country(&self, extractor: fn(&TakedownReason) -> Option<&str>) -> bool { - let viewer_country = self.ctx.viewer.country_code.as_deref(); + let viewer_country = self + .ctx + .viewer + .account_country_code + .as_deref() + .or(self.ctx.viewer.country_code.as_deref()); self.ctx .candidate .tweet_features @@ -278,8 +283,9 @@ impl TakedownPredicates<'_> { let country = self .ctx .viewer - .country_code + .account_country_code .as_deref() + .or(self.ctx.viewer.country_code.as_deref()) .unwrap_or(WORLDWIDE_COUNTRY_CODE); let allow = &self.ctx.candidate.tweet_features.media.geo_allow_list; let deny = &self.ctx.candidate.tweet_features.media.geo_deny_list; diff --git a/visibility-filtering/rules/golden_corpus.rs b/visibility-filtering/rules/golden_corpus.rs index cc4da723..7ea76f97 100644 --- a/visibility-filtering/rules/golden_corpus.rs +++ b/visibility-filtering/rules/golden_corpus.rs @@ -171,6 +171,13 @@ fn viewer_in_country(code: &str) -> ViewerFeatures { } } +fn viewer_with_account_country(code: &str) -> ViewerFeatures { + ViewerFeatures { + account_country_code: Some(code.to_string()), + ..viewer(VIEWER_ID) + } +} + fn viewer_with_age(age: ViewerAge) -> ViewerFeatures { ViewerFeatures { viewer_age: age, @@ -802,6 +809,22 @@ fn oon_media_cases() -> Vec { expected_action: Drop(FilteredReason::UnspecifiedReason), expected_decided_by: Some("DropTweetsWithGeoRestrictedMediaRule"), }, + Case { + name: "geo_allow_listed_media_allows_account_country_when_request_country_missing", + level: TimelineHomeRecommendations, + viewer: viewer_with_account_country("us"), + candidate: tweet_candidate(|t| t.media.geo_allow_list = vec!["us".to_string()]), + expected_action: Allow, + expected_decided_by: None, + }, + Case { + name: "geo_denied_media_drops_account_country_oon", + level: TimelineHomeRecommendations, + viewer: viewer_with_account_country("de"), + candidate: tweet_candidate(|t| t.media.geo_deny_list = vec!["de".to_string()]), + expected_action: Drop(FilteredReason::UnspecifiedReason), + expected_decided_by: Some("DropTweetsWithGeoRestrictedMediaRule"), + }, Case { name: "nsfw_user_author_drops_oon", level: TimelineHomeRecommendations,