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

Commit

Permalink
Initial parsing of withheld_* fields.
Browse files Browse the repository at this point in the history
Close #647
  • Loading branch information
llrs committed Feb 8, 2022
1 parent c798468 commit 40324ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
- Message are now properly capitalized (#565, @jsta)
- Fields `withheld_scope`, `withheld_copyright`, `withheld_in_countries` are now correctly parsed (#647).
- Banned or protected accounts now trigger a warning instead of an error (#590)
- `get_friends()` and `get_followers()` return similar formatted output with
Expand Down
4 changes: 3 additions & 1 deletion R/tweet_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ tweet <- function(x) {
metadata = NA,
query = NA,
user = I(list(list())),
withheld_scope = NA_character_,
withheld_copyright = NA,
withheld_in_countries = NA_character_,
possibly_sensitive_appealable = NA)
if (NROW(x) == 0) {
return(empty)
}

tb <- x
# Some fields seem to depend on what is needed
# possibly_sensitive, full_text, extended_entities
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-tweet_object.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test_that("tweet works with withheld_* #647", {
lu <- rtweet::lookup_tweets("1168343686863892480")
expect_true(is.data.frame(lu))
expect_true(lu$withheld_copyright)
expect_equal(lu$withheld_in_countries, list("XY"))
expect_equal(lu$withheld_scope, "status")
})

0 comments on commit 40324ad

Please sign in to comment.