From 49b16cfd7723faea632b95058b25cfdde2300897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20He=C3=9F?= Date: Mon, 12 Jul 2021 19:57:05 +0200 Subject: [PATCH 01/19] added "blocking" --- R/post-user.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/post-user.R b/R/post-user.R index 34ef2e1b..c2ff63b0 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -22,9 +22,12 @@ #' Create: #' Destroy: #' Mute: +#' Block: + post_follow <- function(user, destroy = FALSE, mute = FALSE, + block = FALSE, notify = FALSE, retweets = TRUE, token = NULL) { @@ -36,6 +39,9 @@ post_follow <- function(user, params <- list( notify = notify, retweets = retweets) + } else if (block) { + query <- "/1.1/blocks/users/create" + params <- list() } else if (mute) { query <- "/1.1/mutes/users/create" params <- list() From 34cd4db2db0b6a248cd77af4808e13056877cdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20He=C3=9F?= Date: Mon, 12 Jul 2021 20:03:19 +0200 Subject: [PATCH 02/19] Update post-user.R --- R/post-user.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/post-user.R b/R/post-user.R index c2ff63b0..c2d833b1 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -40,7 +40,7 @@ post_follow <- function(user, notify = notify, retweets = retweets) } else if (block) { - query <- "/1.1/blocks/users/create" + query <- "/1.1/blocks/create" params <- list() } else if (mute) { query <- "/1.1/mutes/users/create" From ba3cf6e78e74725df730a0a9cd07251f64491623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20He=C3=9F?= Date: Mon, 12 Jul 2021 20:09:13 +0200 Subject: [PATCH 03/19] Update post-user.R --- R/post-user.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/R/post-user.R b/R/post-user.R index c2d833b1..78c9812f 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -6,6 +6,10 @@ #' @param mute Logical indicating whether to mute the intended #' friend (you must already be following this account prior #' to muting them) +#' @param block Logical indicating whether to block the intended +#' friend +#' @param unblock Logical indicating whether to unblock the intended +#' friend #' @param notify Logical indicating whether to enable notifications #' for target user. Defaults to false. #' @param retweets Logical indicating whether to enable retweets @@ -42,6 +46,9 @@ post_follow <- function(user, } else if (block) { query <- "/1.1/blocks/create" params <- list() + } else if (unblock) { + query <- "/1.1/blocks/destroy" + params <- list() } else if (mute) { query <- "/1.1/mutes/users/create" params <- list() @@ -77,6 +84,22 @@ post_mute <- function(user, token = NULL) { post_follow(user, mute = TRUE, token = token) } +#' @aliases unfollow_user +#' @rdname post_follow +#' @aliases mute_user +#' @export +post_block <- function(user, token = NULL) { + post_follow(user, block = TRUE, token = token) +} + +#' @aliases unfollow_user +#' @rdname post_follow +#' @aliases mute_user +#' @export +post_unblock <- function(user, token = NULL) { + post_follow(user, unblock = TRUE, token = token) +} + #' Updates friendship notifications and retweet abilities. #' #' @inheritParams get_timeline From e79a4118ebf3b57913319b8e23eff65f0151bbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20He=C3=9F?= Date: Mon, 12 Jul 2021 20:11:41 +0200 Subject: [PATCH 04/19] Update post-user.R --- R/post-user.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/post-user.R b/R/post-user.R index 78c9812f..ca2b136f 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -31,6 +31,7 @@ post_follow <- function(user, destroy = FALSE, mute = FALSE, + unblock = FALSE, block = FALSE, notify = FALSE, retweets = TRUE, From f6833fcfd71866702902428de92ee49b9b2081e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20He=C3=9F?= Date: Mon, 12 Jul 2021 20:18:16 +0200 Subject: [PATCH 05/19] Update post_follow.Rd --- man/post_follow.Rd | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/man/post_follow.Rd b/man/post_follow.Rd index 5cf96cb7..439fe3ad 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -6,13 +6,17 @@ \alias{post_unfollow_user} \alias{unfollow_user} \alias{post_mute} +\alias{post_block} +\alias{post_unblock} \alias{mute_user} -\title{Follows target twitter user.} +\title{Follows/blocks/mutess target twitter user.} \usage{ post_follow( user, destroy = FALSE, mute = FALSE, + block = FALSE, + unblock = FALSE, notify = FALSE, retweets = TRUE, token = NULL @@ -21,6 +25,10 @@ post_follow( post_unfollow_user(user, token = NULL) post_mute(user, token = NULL) + +post_block(user, token = NULL) + +post_unblock(user, token = NULL) } \arguments{ \item{user}{Character vector of screen names or user ids. @@ -33,6 +41,12 @@ remove (delete) target tweet as favorite.} friend (you must already be following this account prior to muting them)} +\item{block}{Logical indicating whether to block the intended +friend.} + +\item{unblock}{Logical indicating whether to unblock the intended +friend} + \item{notify}{Logical indicating whether to enable notifications for target user. Defaults to false.} @@ -48,6 +62,10 @@ Follows target twitter user. } \examples{ \dontrun{ +post_block("BarackObama") + +post_unblock("BarackObama") + post_follow("BarackObama") } } From 33a8d838fb2b54ac3069c97dfc1ff603707cfb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20He=C3=9F?= Date: Mon, 12 Jul 2021 20:27:24 +0200 Subject: [PATCH 06/19] Update post-user.R --- R/post-user.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/post-user.R b/R/post-user.R index ca2b136f..3f9d48b1 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -85,17 +85,13 @@ post_mute <- function(user, token = NULL) { post_follow(user, mute = TRUE, token = token) } -#' @aliases unfollow_user #' @rdname post_follow -#' @aliases mute_user #' @export post_block <- function(user, token = NULL) { post_follow(user, block = TRUE, token = token) } -#' @aliases unfollow_user #' @rdname post_follow -#' @aliases mute_user #' @export post_unblock <- function(user, token = NULL) { post_follow(user, unblock = TRUE, token = token) From 89aeb9f2d1eaadc52071060122ec4b1bf9ee1534 Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 10:54:58 +0200 Subject: [PATCH 07/19] update RD --- NAMESPACE | 2 ++ man/post_follow.Rd | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 32207c4b..e1f80bfb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -53,6 +53,7 @@ export(network_graph) export(next_cursor) export(parse_stream) export(plain_tweets) +export(post_block) export(post_destroy) export(post_favorite) export(post_follow) @@ -61,6 +62,7 @@ export(post_list) export(post_message) export(post_mute) export(post_tweet) +export(post_unblock) export(post_unfollow_user) export(previous_cursor) export(rate_limit) diff --git a/man/post_follow.Rd b/man/post_follow.Rd index 439fe3ad..bf0f5a10 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -6,17 +6,17 @@ \alias{post_unfollow_user} \alias{unfollow_user} \alias{post_mute} +\alias{mute_user} \alias{post_block} \alias{post_unblock} -\alias{mute_user} -\title{Follows/blocks/mutess target twitter user.} +\title{Follows target twitter user.} \usage{ post_follow( user, destroy = FALSE, mute = FALSE, - block = FALSE, unblock = FALSE, + block = FALSE, notify = FALSE, retweets = TRUE, token = NULL @@ -41,12 +41,12 @@ remove (delete) target tweet as favorite.} friend (you must already be following this account prior to muting them)} -\item{block}{Logical indicating whether to block the intended -friend.} - \item{unblock}{Logical indicating whether to unblock the intended friend} +\item{block}{Logical indicating whether to block the intended +friend} + \item{notify}{Logical indicating whether to enable notifications for target user. Defaults to false.} @@ -62,10 +62,6 @@ Follows target twitter user. } \examples{ \dontrun{ -post_block("BarackObama") - -post_unblock("BarackObama") - post_follow("BarackObama") } } @@ -74,6 +70,7 @@ Update: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-u Create: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create} Destroy: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy} Mute: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-create} +Block: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create} } \seealso{ Other post: From d899b8e1d05ca68075cc29008edf00fb4abcdff0 Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 10:59:58 +0200 Subject: [PATCH 08/19] test for blocking --- tests/testthat/test-post-user.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testthat/test-post-user.R b/tests/testthat/test-post-user.R index 48387c64..5031b168 100644 --- a/tests/testthat/test-post-user.R +++ b/tests/testthat/test-post-user.R @@ -23,3 +23,12 @@ test_that("Muting #467", { pf <- post_follow("hlynur", destroy = TRUE, mute = FALSE, notify = TRUE) expect_equal(httr::status_code(pf), 200L) }) + +test_that("blocking and unblocking users", { + pf <- post_block("s_hesz") + expect_equal(httr::status_code(pf), 200L) + + # Unmutting without following + pf <- post_unblock("s_hesz") + expect_equal(httr::status_code(pf), 200L) +}) From 61d42dfb1489ced5fd33b0876f2363a805a92044 Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 14:26:24 +0200 Subject: [PATCH 09/19] post-block.R now has the code for [un]blocking that was in post-follow before --- R/post-block.R | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 R/post-block.R diff --git a/R/post-block.R b/R/post-block.R new file mode 100644 index 00000000..54e70f24 --- /dev/null +++ b/R/post-block.R @@ -0,0 +1,45 @@ +#' Follows target twitter user. +#' +#' @inheritParams get_timeline +#' @param block Logical indicating whether to block the intended +#' friend +#' @param unblock Logical indicating whether to unblock the intended +#' friend +#' @aliases post_unblock +#' @examples +#' \dontrun{ +#' post_block("BarackObama") +#' post_unblock("BarackObama") +#' post_block("BarackObama") +#' post_block("BarackObama", unblock=TRUE) +#' } +#' @family post +#' @export +#' @references +#' Block: + +post_block <- function(user, + unblock = FALSE, + token = NULL) { + + stopifnot(is.atomic(user), is.logical(notify)) + + if (!unblock) { + query <- "/1.1/blocks/create" + params <- list() + } else { + query <- "/1.1/blocks/destroy" + params <- list() + } + params[[user_type(user)]] <- user + + TWIT_post(token, query, params) +} + + +#' @rdname post_block +#' @export +post_unblock <- function(user, token = NULL) { + post_block(user, unblock = TRUE, token = token) +} + From cb4a4a56b2b607e091031e69b08531f23cd5e21f Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 14:28:24 +0200 Subject: [PATCH 10/19] blocking taken out of post-user.R again --- R/post-user.R | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/R/post-user.R b/R/post-user.R index 3f9d48b1..34ef2e1b 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -6,10 +6,6 @@ #' @param mute Logical indicating whether to mute the intended #' friend (you must already be following this account prior #' to muting them) -#' @param block Logical indicating whether to block the intended -#' friend -#' @param unblock Logical indicating whether to unblock the intended -#' friend #' @param notify Logical indicating whether to enable notifications #' for target user. Defaults to false. #' @param retweets Logical indicating whether to enable retweets @@ -26,13 +22,9 @@ #' Create: #' Destroy: #' Mute: -#' Block: - post_follow <- function(user, destroy = FALSE, mute = FALSE, - unblock = FALSE, - block = FALSE, notify = FALSE, retweets = TRUE, token = NULL) { @@ -44,12 +36,6 @@ post_follow <- function(user, params <- list( notify = notify, retweets = retweets) - } else if (block) { - query <- "/1.1/blocks/create" - params <- list() - } else if (unblock) { - query <- "/1.1/blocks/destroy" - params <- list() } else if (mute) { query <- "/1.1/mutes/users/create" params <- list() @@ -85,18 +71,6 @@ post_mute <- function(user, token = NULL) { post_follow(user, mute = TRUE, token = token) } -#' @rdname post_follow -#' @export -post_block <- function(user, token = NULL) { - post_follow(user, block = TRUE, token = token) -} - -#' @rdname post_follow -#' @export -post_unblock <- function(user, token = NULL) { - post_follow(user, unblock = TRUE, token = token) -} - #' Updates friendship notifications and retweet abilities. #' #' @inheritParams get_timeline From 0539cf3f07ab9c2e57efa7877a48202d0698a4bc Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 14:51:48 +0200 Subject: [PATCH 11/19] doc update --- R/post-block.R | 10 +++---- man/post_block.Rd | 47 ++++++++++++++++++++++++++++++++ man/post_favorite.Rd | 1 + man/post_follow.Rd | 16 +---------- man/post_friendship.Rd | 1 + man/post_tweet.Rd | 1 + tests/testthat/test-post-block.R | 8 ++++++ tests/testthat/test-post-user.R | 9 ------ 8 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 man/post_block.Rd create mode 100644 tests/testthat/test-post-block.R diff --git a/R/post-block.R b/R/post-block.R index 54e70f24..039c1387 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -1,8 +1,9 @@ -#' Follows target twitter user. +#' Blocking or unblocking twitter users +#' +#' `post_block(...)` blocks or unblocks a target twitter user. +#' `post_unblock(...)` is synonymous to `post_block(..., unblock=TRUE)` #' #' @inheritParams get_timeline -#' @param block Logical indicating whether to block the intended -#' friend #' @param unblock Logical indicating whether to unblock the intended #' friend #' @aliases post_unblock @@ -10,8 +11,7 @@ #' \dontrun{ #' post_block("BarackObama") #' post_unblock("BarackObama") -#' post_block("BarackObama") -#' post_block("BarackObama", unblock=TRUE) +#' post_block("BarackObama", unblock=TRUE) #<-same as the above #' } #' @family post #' @export diff --git a/man/post_block.Rd b/man/post_block.Rd new file mode 100644 index 00000000..8595468c --- /dev/null +++ b/man/post_block.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/post-block.R +\name{post_block} +\alias{post_block} +\alias{post_unblock} +\title{Blocking or unblocking twitter users} +\usage{ +post_block(user, unblock = FALSE, token = NULL) + +post_unblock(user, token = NULL) +} +\arguments{ +\item{user}{Character vector of screen names or user ids. +See \code{\link[=as_screenname]{as_screenname()}} for more details.} + +\item{unblock}{Logical indicating whether to unblock the intended +friend} + +\item{token}{Expert use only. Use this to override authentication for +a single API call. In most cases you are better off changing the +default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} + +\item{block}{Logical indicating whether to block the intended +friend} +} +\description{ +\code{post_block(...)} blocks or unblocks a target twitter user. +\code{post_unblock(...)} is synonymous to \code{post_block(..., unblock=TRUE)} +} +\examples{ +\dontrun{ +post_block("BarackObama") +post_unblock("BarackObama") +post_block("BarackObama", unblock=TRUE) #<-same as the above +} +} +\references{ +Block: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create} +} +\seealso{ +Other post: +\code{\link{post_favorite}()}, +\code{\link{post_follow}()}, +\code{\link{post_friendship}()}, +\code{\link{post_tweet}()} +} +\concept{post} diff --git a/man/post_favorite.Rd b/man/post_favorite.Rd index 53fd5c89..50bf9c95 100644 --- a/man/post_favorite.Rd +++ b/man/post_favorite.Rd @@ -41,6 +41,7 @@ Destroy: \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-a } \seealso{ Other post: +\code{\link{post_block}()}, \code{\link{post_follow}()}, \code{\link{post_friendship}()}, \code{\link{post_tweet}()} diff --git a/man/post_follow.Rd b/man/post_follow.Rd index bf0f5a10..29b24f86 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -7,16 +7,12 @@ \alias{unfollow_user} \alias{post_mute} \alias{mute_user} -\alias{post_block} -\alias{post_unblock} \title{Follows target twitter user.} \usage{ post_follow( user, destroy = FALSE, mute = FALSE, - unblock = FALSE, - block = FALSE, notify = FALSE, retweets = TRUE, token = NULL @@ -25,10 +21,6 @@ post_follow( post_unfollow_user(user, token = NULL) post_mute(user, token = NULL) - -post_block(user, token = NULL) - -post_unblock(user, token = NULL) } \arguments{ \item{user}{Character vector of screen names or user ids. @@ -41,12 +33,6 @@ remove (delete) target tweet as favorite.} friend (you must already be following this account prior to muting them)} -\item{unblock}{Logical indicating whether to unblock the intended -friend} - -\item{block}{Logical indicating whether to block the intended -friend} - \item{notify}{Logical indicating whether to enable notifications for target user. Defaults to false.} @@ -70,10 +56,10 @@ Update: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-u Create: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create} Destroy: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy} Mute: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-create} -Block: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create} } \seealso{ Other post: +\code{\link{post_block}()}, \code{\link{post_favorite}()}, \code{\link{post_friendship}()}, \code{\link{post_tweet}()} diff --git a/man/post_friendship.Rd b/man/post_friendship.Rd index 3dfb0f54..1ccec0be 100644 --- a/man/post_friendship.Rd +++ b/man/post_friendship.Rd @@ -30,6 +30,7 @@ Updates friendship notifications and retweet abilities. } \seealso{ Other post: +\code{\link{post_block}()}, \code{\link{post_favorite}()}, \code{\link{post_follow}()}, \code{\link{post_tweet}()} diff --git a/man/post_tweet.Rd b/man/post_tweet.Rd index 3f47e1bb..06b0f6ae 100644 --- a/man/post_tweet.Rd +++ b/man/post_tweet.Rd @@ -118,6 +118,7 @@ Alt-text: \url{https://developer.twitter.com/en/docs/twitter-api/v1/media/upload } \seealso{ Other post: +\code{\link{post_block}()}, \code{\link{post_favorite}()}, \code{\link{post_follow}()}, \code{\link{post_friendship}()} diff --git a/tests/testthat/test-post-block.R b/tests/testthat/test-post-block.R new file mode 100644 index 00000000..fadf4cf4 --- /dev/null +++ b/tests/testthat/test-post-block.R @@ -0,0 +1,8 @@ +test_that("blocking and unblocking users", { + pf <- post_block("s_hesz") + expect_equal(httr::status_code(pf), 200L) + + # unblocking + pf <- post_unblock("s_hesz") + expect_equal(httr::status_code(pf), 200L) +}) diff --git a/tests/testthat/test-post-user.R b/tests/testthat/test-post-user.R index 5031b168..48387c64 100644 --- a/tests/testthat/test-post-user.R +++ b/tests/testthat/test-post-user.R @@ -23,12 +23,3 @@ test_that("Muting #467", { pf <- post_follow("hlynur", destroy = TRUE, mute = FALSE, notify = TRUE) expect_equal(httr::status_code(pf), 200L) }) - -test_that("blocking and unblocking users", { - pf <- post_block("s_hesz") - expect_equal(httr::status_code(pf), 200L) - - # Unmutting without following - pf <- post_unblock("s_hesz") - expect_equal(httr::status_code(pf), 200L) -}) From 296593cb731813ebfd8c3815b3a23198ab733f46 Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 14:56:49 +0200 Subject: [PATCH 12/19] fixes to "stopifnot(...)"-checks in post-block and post-user --- R/post-block.R | 2 +- R/post-user.R | 2 +- man/post_block.Rd | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/R/post-block.R b/R/post-block.R index 039c1387..43e07196 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -22,7 +22,7 @@ post_block <- function(user, unblock = FALSE, token = NULL) { - stopifnot(is.atomic(user), is.logical(notify)) + stopifnot(is.atomic(user), is.logical(unblock)) if (!unblock) { query <- "/1.1/blocks/create" diff --git a/R/post-user.R b/R/post-user.R index 34ef2e1b..c2b4ee92 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -29,7 +29,7 @@ post_follow <- function(user, retweets = TRUE, token = NULL) { - stopifnot(is.atomic(user), is.logical(notify)) + stopifnot(is.atomic(user), is.logical(notify), is.logical(mute), is.logical(retweets), is.logical(destroy)) if (all(!destroy, !retweets)) { query <- "/1.1/friendships/update" diff --git a/man/post_block.Rd b/man/post_block.Rd index 8595468c..92ca9bb3 100644 --- a/man/post_block.Rd +++ b/man/post_block.Rd @@ -19,9 +19,6 @@ friend} \item{token}{Expert use only. Use this to override authentication for a single API call. In most cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} - -\item{block}{Logical indicating whether to block the intended -friend} } \description{ \code{post_block(...)} blocks or unblocks a target twitter user. From 3bd3b0f2eaef9fe3f42bb4a767e03c0e1de37146 Mon Sep 17 00:00:00 2001 From: simonheb Date: Tue, 13 Jul 2021 23:31:26 +0200 Subject: [PATCH 13/19] rename post_[un]block to [un]block_user --- NAMESPACE | 4 ++-- R/post-block.R | 18 ++++++++--------- man/{post_block.Rd => block_user.Rd} | 20 +++++++++---------- man/post_favorite.Rd | 2 +- man/post_follow.Rd | 2 +- man/post_friendship.Rd | 2 +- man/post_tweet.Rd | 2 +- man/ts_plot.Rd | 2 +- .../{test-post-block.R => test-block.R} | 4 ++-- 9 files changed, 27 insertions(+), 29 deletions(-) rename man/{post_block.Rd => block_user.Rd} (71%) rename tests/testthat/{test-post-block.R => test-block.R} (71%) diff --git a/NAMESPACE b/NAMESPACE index e1f80bfb..a2e5aa39 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,6 +13,7 @@ export(auth_list) export(auth_save) export(auth_setup_default) export(bearer_token) +export(block_user) export(create_token) export(direct_messages) export(direct_messages_received) @@ -53,7 +54,6 @@ export(network_graph) export(next_cursor) export(parse_stream) export(plain_tweets) -export(post_block) export(post_destroy) export(post_favorite) export(post_follow) @@ -62,7 +62,6 @@ export(post_list) export(post_message) export(post_mute) export(post_tweet) -export(post_unblock) export(post_unfollow_user) export(previous_cursor) export(rate_limit) @@ -90,6 +89,7 @@ export(tweet_shot) export(tweet_threading) export(tweets_data) export(tweets_with_users) +export(unblock_user) export(unflatten) export(users_data) export(users_with_tweets) diff --git a/R/post-block.R b/R/post-block.R index 43e07196..31c4d5de 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -1,24 +1,24 @@ #' Blocking or unblocking twitter users #' -#' `post_block(...)` blocks or unblocks a target twitter user. -#' `post_unblock(...)` is synonymous to `post_block(..., unblock=TRUE)` +#' `block_user(...)` blocks or unblocks a target twitter user. +#' `unblock_user(...)` is synonymous to `block_user(..., unblock=TRUE)` #' #' @inheritParams get_timeline #' @param unblock Logical indicating whether to unblock the intended #' friend -#' @aliases post_unblock +#' @aliases unblock_user #' @examples #' \dontrun{ -#' post_block("BarackObama") -#' post_unblock("BarackObama") -#' post_block("BarackObama", unblock=TRUE) #<-same as the above +#' block_user("BarackObama") +#' unblock_user("BarackObama") +#' block_user("BarackObama", unblock=TRUE) #<-same as the above #' } #' @family post #' @export #' @references #' Block: -post_block <- function(user, +block_user <- function(user, unblock = FALSE, token = NULL) { @@ -39,7 +39,7 @@ post_block <- function(user, #' @rdname post_block #' @export -post_unblock <- function(user, token = NULL) { - post_block(user, unblock = TRUE, token = token) +unblock_user <- function(user, token = NULL) { + block_user(user, unblock = TRUE, token = token) } diff --git a/man/post_block.Rd b/man/block_user.Rd similarity index 71% rename from man/post_block.Rd rename to man/block_user.Rd index 92ca9bb3..5210f1d9 100644 --- a/man/post_block.Rd +++ b/man/block_user.Rd @@ -1,13 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/post-block.R -\name{post_block} -\alias{post_block} -\alias{post_unblock} +\name{block_user} +\alias{block_user} +\alias{unblock_user} \title{Blocking or unblocking twitter users} \usage{ -post_block(user, unblock = FALSE, token = NULL) - -post_unblock(user, token = NULL) +block_user(user, unblock = FALSE, token = NULL) } \arguments{ \item{user}{Character vector of screen names or user ids. @@ -21,14 +19,14 @@ a single API call. In most cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ -\code{post_block(...)} blocks or unblocks a target twitter user. -\code{post_unblock(...)} is synonymous to \code{post_block(..., unblock=TRUE)} +\code{block_user(...)} blocks or unblocks a target twitter user. +\code{unblock_user(...)} is synonymous to \code{block_user(..., unblock=TRUE)} } \examples{ \dontrun{ -post_block("BarackObama") -post_unblock("BarackObama") -post_block("BarackObama", unblock=TRUE) #<-same as the above +block_user("BarackObama") +unblock_user("BarackObama") +block_user("BarackObama", unblock=TRUE) #<-same as the above } } \references{ diff --git a/man/post_favorite.Rd b/man/post_favorite.Rd index 50bf9c95..b806da91 100644 --- a/man/post_favorite.Rd +++ b/man/post_favorite.Rd @@ -41,7 +41,7 @@ Destroy: \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-a } \seealso{ Other post: -\code{\link{post_block}()}, +\code{\link{block_user}()}, \code{\link{post_follow}()}, \code{\link{post_friendship}()}, \code{\link{post_tweet}()} diff --git a/man/post_follow.Rd b/man/post_follow.Rd index 29b24f86..1adce672 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -59,7 +59,7 @@ Mute: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-use } \seealso{ Other post: -\code{\link{post_block}()}, +\code{\link{block_user}()}, \code{\link{post_favorite}()}, \code{\link{post_friendship}()}, \code{\link{post_tweet}()} diff --git a/man/post_friendship.Rd b/man/post_friendship.Rd index 1ccec0be..dc540d73 100644 --- a/man/post_friendship.Rd +++ b/man/post_friendship.Rd @@ -30,7 +30,7 @@ Updates friendship notifications and retweet abilities. } \seealso{ Other post: -\code{\link{post_block}()}, +\code{\link{block_user}()}, \code{\link{post_favorite}()}, \code{\link{post_follow}()}, \code{\link{post_tweet}()} diff --git a/man/post_tweet.Rd b/man/post_tweet.Rd index 06b0f6ae..f6ee3659 100644 --- a/man/post_tweet.Rd +++ b/man/post_tweet.Rd @@ -118,7 +118,7 @@ Alt-text: \url{https://developer.twitter.com/en/docs/twitter-api/v1/media/upload } \seealso{ Other post: -\code{\link{post_block}()}, +\code{\link{block_user}()}, \code{\link{post_favorite}()}, \code{\link{post_follow}()}, \code{\link{post_friendship}()} diff --git a/man/ts_plot.Rd b/man/ts_plot.Rd index 8fd86b32..72024774 100644 --- a/man/ts_plot.Rd +++ b/man/ts_plot.Rd @@ -20,7 +20,7 @@ and end of the time series.} \item{tz}{Time zone to be used, defaults to "UTC" (Twitter default)} \item{...}{Other arguments passed to -\code{\link[ggplot2:geom_path]{ggplot2::geom_line()}}.} +\code{\link[ggplot2:geom_line]{ggplot2::geom_line()}}.} } \value{ If diff --git a/tests/testthat/test-post-block.R b/tests/testthat/test-block.R similarity index 71% rename from tests/testthat/test-post-block.R rename to tests/testthat/test-block.R index fadf4cf4..300c607b 100644 --- a/tests/testthat/test-post-block.R +++ b/tests/testthat/test-block.R @@ -1,8 +1,8 @@ test_that("blocking and unblocking users", { - pf <- post_block("s_hesz") + pf <- block_user("s_hesz") expect_equal(httr::status_code(pf), 200L) # unblocking - pf <- post_unblock("s_hesz") + pf <- unblock_user("s_hesz") expect_equal(httr::status_code(pf), 200L) }) From 6860147133120a4f6f84392b0ac7c7d04f178a4c Mon Sep 17 00:00:00 2001 From: simonheb Date: Wed, 21 Jul 2021 15:23:35 +0200 Subject: [PATCH 14/19] ranme block_user to user_block --- NAMESPACE | 4 ++-- R/post-block.R | 19 +++++++++---------- man/post_favorite.Rd | 4 ++-- man/post_follow.Rd | 4 ++-- man/post_friendship.Rd | 4 ++-- man/post_tweet.Rd | 4 ++-- man/ts_plot.Rd | 2 +- man/{block_user.Rd => user_block.Rd} | 19 ++++++++++--------- tests/testthat/test-block.R | 4 ++-- 9 files changed, 32 insertions(+), 32 deletions(-) rename man/{block_user.Rd => user_block.Rd} (69%) diff --git a/NAMESPACE b/NAMESPACE index a2e5aa39..0e9b41ca 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,7 +13,6 @@ export(auth_list) export(auth_save) export(auth_setup_default) export(bearer_token) -export(block_user) export(create_token) export(direct_messages) export(direct_messages_received) @@ -89,8 +88,9 @@ export(tweet_shot) export(tweet_threading) export(tweets_data) export(tweets_with_users) -export(unblock_user) export(unflatten) +export(user_block) +export(user_unblock) export(users_data) export(users_with_tweets) export(write_as_csv) diff --git a/R/post-block.R b/R/post-block.R index 31c4d5de..a43317be 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -1,24 +1,23 @@ #' Blocking or unblocking twitter users #' -#' `block_user(...)` blocks or unblocks a target twitter user. -#' `unblock_user(...)` is synonymous to `block_user(..., unblock=TRUE)` +#' `user_block(...)` blocks or unblocks a target twitter user. ' `user_unblock(...)` is synonymous to `user_block(..., unblock=TRUE)`. #' #' @inheritParams get_timeline #' @param unblock Logical indicating whether to unblock the intended #' friend -#' @aliases unblock_user +#' @aliases user_unblock #' @examples #' \dontrun{ -#' block_user("BarackObama") -#' unblock_user("BarackObama") -#' block_user("BarackObama", unblock=TRUE) #<-same as the above +#' user_block("BarackObama") +#' user_unblock("BarackObama") +#' user_block("BarackObama", unblock=TRUE) #<-same as the above #' } #' @family post #' @export #' @references #' Block: -block_user <- function(user, +user_block <- function(user, unblock = FALSE, token = NULL) { @@ -37,9 +36,9 @@ block_user <- function(user, } -#' @rdname post_block +#' @rdname user_block #' @export -unblock_user <- function(user, token = NULL) { - block_user(user, unblock = TRUE, token = token) +user_unblock <- function(user, token = NULL) { + user_block(user, unblock = TRUE, token = token) } diff --git a/man/post_favorite.Rd b/man/post_favorite.Rd index b806da91..eb58e76c 100644 --- a/man/post_favorite.Rd +++ b/man/post_favorite.Rd @@ -41,9 +41,9 @@ Destroy: \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-a } \seealso{ Other post: -\code{\link{block_user}()}, \code{\link{post_follow}()}, \code{\link{post_friendship}()}, -\code{\link{post_tweet}()} +\code{\link{post_tweet}()}, +\code{\link{user_block}()} } \concept{post} diff --git a/man/post_follow.Rd b/man/post_follow.Rd index 1adce672..1b266385 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -59,9 +59,9 @@ Mute: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-use } \seealso{ Other post: -\code{\link{block_user}()}, \code{\link{post_favorite}()}, \code{\link{post_friendship}()}, -\code{\link{post_tweet}()} +\code{\link{post_tweet}()}, +\code{\link{user_block}()} } \concept{post} diff --git a/man/post_friendship.Rd b/man/post_friendship.Rd index dc540d73..df70e7a5 100644 --- a/man/post_friendship.Rd +++ b/man/post_friendship.Rd @@ -30,9 +30,9 @@ Updates friendship notifications and retweet abilities. } \seealso{ Other post: -\code{\link{block_user}()}, \code{\link{post_favorite}()}, \code{\link{post_follow}()}, -\code{\link{post_tweet}()} +\code{\link{post_tweet}()}, +\code{\link{user_block}()} } \concept{post} diff --git a/man/post_tweet.Rd b/man/post_tweet.Rd index f6ee3659..65e69fef 100644 --- a/man/post_tweet.Rd +++ b/man/post_tweet.Rd @@ -118,9 +118,9 @@ Alt-text: \url{https://developer.twitter.com/en/docs/twitter-api/v1/media/upload } \seealso{ Other post: -\code{\link{block_user}()}, \code{\link{post_favorite}()}, \code{\link{post_follow}()}, -\code{\link{post_friendship}()} +\code{\link{post_friendship}()}, +\code{\link{user_block}()} } \concept{post} diff --git a/man/ts_plot.Rd b/man/ts_plot.Rd index 72024774..8fd86b32 100644 --- a/man/ts_plot.Rd +++ b/man/ts_plot.Rd @@ -20,7 +20,7 @@ and end of the time series.} \item{tz}{Time zone to be used, defaults to "UTC" (Twitter default)} \item{...}{Other arguments passed to -\code{\link[ggplot2:geom_line]{ggplot2::geom_line()}}.} +\code{\link[ggplot2:geom_path]{ggplot2::geom_line()}}.} } \value{ If diff --git a/man/block_user.Rd b/man/user_block.Rd similarity index 69% rename from man/block_user.Rd rename to man/user_block.Rd index 5210f1d9..d2441000 100644 --- a/man/block_user.Rd +++ b/man/user_block.Rd @@ -1,11 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/post-block.R -\name{block_user} -\alias{block_user} -\alias{unblock_user} +\name{user_block} +\alias{user_block} +\alias{user_unblock} \title{Blocking or unblocking twitter users} \usage{ -block_user(user, unblock = FALSE, token = NULL) +user_block(user, unblock = FALSE, token = NULL) + +user_unblock(user, token = NULL) } \arguments{ \item{user}{Character vector of screen names or user ids. @@ -19,14 +21,13 @@ a single API call. In most cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ -\code{block_user(...)} blocks or unblocks a target twitter user. -\code{unblock_user(...)} is synonymous to \code{block_user(..., unblock=TRUE)} +\code{user_block(...)} blocks or unblocks a target twitter user. ' \code{user_unblock(...)} is synonymous to \code{user_block(..., unblock=TRUE)}. } \examples{ \dontrun{ -block_user("BarackObama") -unblock_user("BarackObama") -block_user("BarackObama", unblock=TRUE) #<-same as the above +user_block("BarackObama") +user_unblock("BarackObama") +user_block("BarackObama", unblock=TRUE) #<-same as the above } } \references{ diff --git a/tests/testthat/test-block.R b/tests/testthat/test-block.R index 300c607b..68a840d7 100644 --- a/tests/testthat/test-block.R +++ b/tests/testthat/test-block.R @@ -1,8 +1,8 @@ test_that("blocking and unblocking users", { - pf <- block_user("s_hesz") + pf <- user_block("s_hesz") expect_equal(httr::status_code(pf), 200L) # unblocking - pf <- unblock_user("s_hesz") + pf <- user_unblock("s_hesz") expect_equal(httr::status_code(pf), 200L) }) From 85e58fc55005b77486df57469b160a3c3c27e2e3 Mon Sep 17 00:00:00 2001 From: simonheb Date: Thu, 12 Aug 2021 10:55:35 +0200 Subject: [PATCH 15/19] fix to pass on token --- R/post-tweet.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/post-tweet.R b/R/post-tweet.R index 74c51f63..b023f38c 100644 --- a/R/post-tweet.R +++ b/R/post-tweet.R @@ -96,7 +96,7 @@ post_tweet <- function(status = "my first rtweet #rstats", ## if delete if (!is.null(destroy_id)) { lifecycle::deprecate_warn("1.0.0", "post_tweet(destroy_id)", "post_destroy()") - return(post_destroy(destroy_id)) + return(post_destroy(destroy_id, token=token)) } ## if retweet From 4115d9188f1e128e6c2ba6b52dcea2c934104dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Sat, 26 Mar 2022 18:10:10 +0100 Subject: [PATCH 16/19] Revert some changes when blocking would be in post_follow --- R/post-user.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/post-user.R b/R/post-user.R index c2b4ee92..34ef2e1b 100644 --- a/R/post-user.R +++ b/R/post-user.R @@ -29,7 +29,7 @@ post_follow <- function(user, retweets = TRUE, token = NULL) { - stopifnot(is.atomic(user), is.logical(notify), is.logical(mute), is.logical(retweets), is.logical(destroy)) + stopifnot(is.atomic(user), is.logical(notify)) if (all(!destroy, !retweets)) { query <- "/1.1/friendships/update" From cab2b6c1ed355fe70548ac5d2ac5ecbbfae5a9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Sat, 26 Mar 2022 18:34:06 +0100 Subject: [PATCH 17/19] Testing for blocking/unblocking --- R/post-block.R | 7 +- tests/fixtures/block.yml | 107 +++++++++++++++++++++++++++++++ tests/testthat/test-post-block.R | 8 +++ 3 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 tests/fixtures/block.yml create mode 100644 tests/testthat/test-post-block.R diff --git a/R/post-block.R b/R/post-block.R index a43317be..a77d52e7 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -1,10 +1,11 @@ #' Blocking or unblocking twitter users #' -#' `user_block(...)` blocks or unblocks a target twitter user. ' `user_unblock(...)` is synonymous to `user_block(..., unblock=TRUE)`. +#' `user_block(...)` blocks or unblocks a target twitter user. +#' `user_unblock(...)` is synonymous to `user_block(..., unblock=TRUE)`. #' #' @inheritParams get_timeline #' @param unblock Logical indicating whether to unblock the intended -#' friend +#' friend. #' @aliases user_unblock #' @examples #' \dontrun{ @@ -12,11 +13,9 @@ #' user_unblock("BarackObama") #' user_block("BarackObama", unblock=TRUE) #<-same as the above #' } -#' @family post #' @export #' @references #' Block: - user_block <- function(user, unblock = FALSE, token = NULL) { diff --git a/tests/fixtures/block.yml b/tests/fixtures/block.yml new file mode 100644 index 00000000..725a1992 --- /dev/null +++ b/tests/fixtures/block.yml @@ -0,0 +1,107 @@ +http_interactions: +- request: + method: post + uri: https://api.twitter.com/1.1/blocks/create.json?screen_name=BarackObama + body: + encoding: '' + string: '' + headers: + Accept: application/json, text/xml, application/xml, */* + Content-Type: '' + Authorization: My oauth token is safe + response: + status: + status_code: 200 + category: Success + reason: OK + message: 'Success: (200) OK' + headers: + cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0 + content-disposition: attachment; filename=json.json + content-encoding: gzip + content-length: '1154' + content-type: application/json;charset=utf-8 + date: Sat, 26 Mar 2022 17:32:24 GMT + expires: Tue, 31 Mar 1981 05:00:00 GMT + last-modified: Sat, 26 Mar 2022 17:32:24 GMT + pragma: no-cache + server: tsa_f + set-cookie: + - lang=en; Path=/ + - guest_id=v1%3A164831594482167658; Max-Age=34214400; Expires=Wed, 26 Apr 2023 + 17:32:24 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None + status: 200 OK + strict-transport-security: max-age=631138519 + x-access-level: read-write-directmessages + x-connection-hash: 5894cbd441c135766ac58c25ab01ed9a000a13bdd8e2791e41ca907477e79d64 + x-content-type-options: nosniff + x-frame-options: SAMEORIGIN + x-response-time: '189' + x-transaction: cd0da8b439801c49 + x-twitter-response-tags: BouncerCompliant + x-xss-protection: '0' + body: + encoding: UTF-8 + file: no + string: '{"id":813286,"id_str":"813286","name":"Barack Obama","screen_name":"BarackObama","location":"Washington, + DC","description":"Dad, husband, President, citizen.","url":"https:\/\/t.co\/kHvnxozw8x","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/kHvnxozw8x","expanded_url":"http:\/\/obamabook.com","display_url":"obamabook.com","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":131369806,"friends_count":586073,"listed_count":222245,"created_at":"Mon + Mar 05 22:08:25 +0000 2007","favourites_count":0,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":true,"statuses_count":16417,"lang":null,"status":{"created_at":"Thu + Mar 24 20:00:48 +0000 2022","id":1507085038940262408,"id_str":"1507085038940262408","text":"Today + @POTUS announced that the U.S. will be welcoming 100,000 refugees fleeing + the war in Ukraine.\n\u00a0\nThis is the r\u2026 https:\/\/t.co\/wlyZASCR4i","truncated":true,"entities":{"hashtags":[],"symbols":[],"user_mentions":[{"screen_name":"POTUS","name":"President + Biden","id":1349149096909668363,"id_str":"1349149096909668363","indices":[6,12]}],"urls":[{"url":"https:\/\/t.co\/wlyZASCR4i","expanded_url":"https:\/\/twitter.com\/i\/web\/status\/1507085038940262408","display_url":"twitter.com\/i\/web\/status\/1\u2026","indices":[117,140]}]},"source":"\u003ca + href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter + for iPhone\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":2066,"favorite_count":12965,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"contributors_enabled":false,"is_translator":false,"is_translation_enabled":true,"profile_background_color":"77B0DC","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/1329647526807543809\/2SGvnHYV_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/1329647526807543809\/2SGvnHYV_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/813286\/1633800288","profile_link_color":"2574AD","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"C2E0F6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"muting":false,"translator_type":"regular","withheld_in_countries":[]}' + recorded_at: 2022-03-26 17:32:25 GMT + recorded_with: vcr/1.0.2, webmockr/0.8.0 +- request: + method: post + uri: https://api.twitter.com/1.1/blocks/destroy.json?screen_name=BarackObama + body: + encoding: '' + string: '' + headers: + Accept: application/json, text/xml, application/xml, */* + Content-Type: '' + Authorization: My oauth token is safe + response: + status: + status_code: 200 + category: Success + reason: OK + message: 'Success: (200) OK' + headers: + date: Sat, 26 Mar 2022 17:32:25 GMT + pragma: no-cache + server: tsa_f + status: 200 OK + expires: Tue, 31 Mar 1981 05:00:00 GMT + content-type: application/json;charset=utf-8 + cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0 + last-modified: Sat, 26 Mar 2022 17:32:25 GMT + x-transaction: 514601c2cc82f027 + content-length: '1154' + x-access-level: read-write-directmessages + x-frame-options: SAMEORIGIN + content-encoding: gzip + x-xss-protection: '0' + content-disposition: attachment; filename=json.json + x-content-type-options: nosniff + x-twitter-response-tags: BouncerCompliant + strict-transport-security: max-age=631138519 + x-response-time: '184' + x-connection-hash: 5894cbd441c135766ac58c25ab01ed9a000a13bdd8e2791e41ca907477e79d64 + body: + encoding: UTF-8 + file: no + string: '{"id":813286,"id_str":"813286","name":"Barack Obama","screen_name":"BarackObama","location":"Washington, + DC","description":"Dad, husband, President, citizen.","url":"https:\/\/t.co\/kHvnxozw8x","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/kHvnxozw8x","expanded_url":"http:\/\/obamabook.com","display_url":"obamabook.com","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":131369806,"friends_count":586073,"listed_count":222245,"created_at":"Mon + Mar 05 22:08:25 +0000 2007","favourites_count":0,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":true,"statuses_count":16417,"lang":null,"status":{"created_at":"Thu + Mar 24 20:00:48 +0000 2022","id":1507085038940262408,"id_str":"1507085038940262408","text":"Today + @POTUS announced that the U.S. will be welcoming 100,000 refugees fleeing + the war in Ukraine.\n\u00a0\nThis is the r\u2026 https:\/\/t.co\/wlyZASCR4i","truncated":true,"entities":{"hashtags":[],"symbols":[],"user_mentions":[{"screen_name":"POTUS","name":"President + Biden","id":1349149096909668363,"id_str":"1349149096909668363","indices":[6,12]}],"urls":[{"url":"https:\/\/t.co\/wlyZASCR4i","expanded_url":"https:\/\/twitter.com\/i\/web\/status\/1507085038940262408","display_url":"twitter.com\/i\/web\/status\/1\u2026","indices":[117,140]}]},"source":"\u003ca + href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter + for iPhone\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":2066,"favorite_count":12965,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"contributors_enabled":false,"is_translator":false,"is_translation_enabled":true,"profile_background_color":"77B0DC","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/1329647526807543809\/2SGvnHYV_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/1329647526807543809\/2SGvnHYV_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/813286\/1633800288","profile_link_color":"2574AD","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"C2E0F6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"muting":false,"translator_type":"regular","withheld_in_countries":[]}' + recorded_at: 2022-03-26 17:32:25 GMT + recorded_with: vcr/1.0.2, webmockr/0.8.0 diff --git a/tests/testthat/test-post-block.R b/tests/testthat/test-post-block.R new file mode 100644 index 00000000..ecbfb0c0 --- /dev/null +++ b/tests/testthat/test-post-block.R @@ -0,0 +1,8 @@ +vcr::use_cassette("block", { + test_that("blocking works", { + b <- user_block("BarackObama") + expect_equal(httr::status_code(b), 200L) + a <- user_unblock("BarackObama") + expect_equal(httr::status_code(a), 200L) + }) +}) From 9c0ce7a9456698d5dbfa9706a54d0f1b7100501b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Sat, 26 Mar 2022 18:35:30 +0100 Subject: [PATCH 18/19] Update documentation --- man/post_favorite.Rd | 3 +-- man/post_follow.Rd | 3 +-- man/post_friendship.Rd | 3 +-- man/post_tweet.Rd | 3 +-- man/user_block.Rd | 13 +++---------- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/man/post_favorite.Rd b/man/post_favorite.Rd index eb58e76c..53fd5c89 100644 --- a/man/post_favorite.Rd +++ b/man/post_favorite.Rd @@ -43,7 +43,6 @@ Destroy: \url{https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-a Other post: \code{\link{post_follow}()}, \code{\link{post_friendship}()}, -\code{\link{post_tweet}()}, -\code{\link{user_block}()} +\code{\link{post_tweet}()} } \concept{post} diff --git a/man/post_follow.Rd b/man/post_follow.Rd index ad261faa..f01dfda9 100644 --- a/man/post_follow.Rd +++ b/man/post_follow.Rd @@ -61,7 +61,6 @@ Mute: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-use Other post: \code{\link{post_favorite}()}, \code{\link{post_friendship}()}, -\code{\link{post_tweet}()}, -\code{\link{user_block}()} +\code{\link{post_tweet}()} } \concept{post} diff --git a/man/post_friendship.Rd b/man/post_friendship.Rd index df70e7a5..3dfb0f54 100644 --- a/man/post_friendship.Rd +++ b/man/post_friendship.Rd @@ -32,7 +32,6 @@ Updates friendship notifications and retweet abilities. Other post: \code{\link{post_favorite}()}, \code{\link{post_follow}()}, -\code{\link{post_tweet}()}, -\code{\link{user_block}()} +\code{\link{post_tweet}()} } \concept{post} diff --git a/man/post_tweet.Rd b/man/post_tweet.Rd index 65e69fef..3f47e1bb 100644 --- a/man/post_tweet.Rd +++ b/man/post_tweet.Rd @@ -120,7 +120,6 @@ Alt-text: \url{https://developer.twitter.com/en/docs/twitter-api/v1/media/upload Other post: \code{\link{post_favorite}()}, \code{\link{post_follow}()}, -\code{\link{post_friendship}()}, -\code{\link{user_block}()} +\code{\link{post_friendship}()} } \concept{post} diff --git a/man/user_block.Rd b/man/user_block.Rd index d2441000..c82cbc4c 100644 --- a/man/user_block.Rd +++ b/man/user_block.Rd @@ -14,14 +14,15 @@ user_unblock(user, token = NULL) See \code{\link[=as_screenname]{as_screenname()}} for more details.} \item{unblock}{Logical indicating whether to unblock the intended -friend} +friend.} \item{token}{Expert use only. Use this to override authentication for a single API call. In most cases you are better off changing the default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \description{ -\code{user_block(...)} blocks or unblocks a target twitter user. ' \code{user_unblock(...)} is synonymous to \code{user_block(..., unblock=TRUE)}. +\code{user_block(...)} blocks or unblocks a target twitter user. +\code{user_unblock(...)} is synonymous to \code{user_block(..., unblock=TRUE)}. } \examples{ \dontrun{ @@ -33,11 +34,3 @@ user_block("BarackObama", unblock=TRUE) #<-same as the above \references{ Block: \url{https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create} } -\seealso{ -Other post: -\code{\link{post_favorite}()}, -\code{\link{post_follow}()}, -\code{\link{post_friendship}()}, -\code{\link{post_tweet}()} -} -\concept{post} From c90c10355a7c749175742a7923922d781d9b1543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs?= Date: Sat, 26 Mar 2022 18:39:38 +0100 Subject: [PATCH 19/19] Change user used --- R/post-block.R | 6 +++--- man/user_block.Rd | 6 +++--- tests/testthat/test-post-block.R | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/post-block.R b/R/post-block.R index a77d52e7..dcea345a 100644 --- a/R/post-block.R +++ b/R/post-block.R @@ -9,9 +9,9 @@ #' @aliases user_unblock #' @examples #' \dontrun{ -#' user_block("BarackObama") -#' user_unblock("BarackObama") -#' user_block("BarackObama", unblock=TRUE) #<-same as the above +#' user_block("rtweet_test") +#' user_unblock("rtweet_test") +#' user_block("rtweet_test", unblock=TRUE) #<-same as the above #' } #' @export #' @references diff --git a/man/user_block.Rd b/man/user_block.Rd index c82cbc4c..5bed02e0 100644 --- a/man/user_block.Rd +++ b/man/user_block.Rd @@ -26,9 +26,9 @@ default for all calls. See \code{\link[=auth_as]{auth_as()}} for details.} } \examples{ \dontrun{ -user_block("BarackObama") -user_unblock("BarackObama") -user_block("BarackObama", unblock=TRUE) #<-same as the above +user_block("rtweet_test") +user_unblock("rtweet_test") +user_block("rtweet_test", unblock=TRUE) #<-same as the above } } \references{ diff --git a/tests/testthat/test-post-block.R b/tests/testthat/test-post-block.R index ecbfb0c0..fe568205 100644 --- a/tests/testthat/test-post-block.R +++ b/tests/testthat/test-post-block.R @@ -1,8 +1,8 @@ vcr::use_cassette("block", { test_that("blocking works", { - b <- user_block("BarackObama") + b <- user_block("rtweet_test") expect_equal(httr::status_code(b), 200L) - a <- user_unblock("BarackObama") + a <- user_unblock("rtweet_test") expect_equal(httr::status_code(a), 200L) }) })