Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions visibility-filtering/rules/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions visibility-filtering/rules/golden_corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -802,6 +809,22 @@ fn oon_media_cases() -> Vec<Case> {
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,
Expand Down