Skip to content

Commit

Permalink
Close most issues (#55)
Browse files Browse the repository at this point in the history
Fail if toots fail. Closes #7.
Clarify call to action. Closes #51.
Automatically update the LI API version. Closes #54.
  • Loading branch information
jonthegeek authored Oct 20, 2024
1 parent dbc1008 commit fd2c5fe
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 72 deletions.
11 changes: 10 additions & 1 deletion helpers-linkedin.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ li_client <- httr2::oauth_client(
# TODO: Make this work with code.
# https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?tabs=HTTPS1#step-2-request-an-authorization-code

# Automatically set the LinkedIn API version to 2 months ago since they
# constantly change that without changing core features.
li_version_date <- lubridate::rollback(lubridate::rollback(lubridate::today()))

li_version <- paste0(
lubridate::year(li_version_date),
stringr::str_pad(lubridate::month(li_version_date), 2, pad = "0")
)

li_base <- httr2::request("https://api.linkedin.com/rest") |>
httr2::req_oauth_refresh(
client = li_client,
refresh_token = Sys.getenv("LI_REFRESH_TOKEN"),
scope = "r_basicprofile,r_emailaddress,r_liteprofile,r_member_social,r_organization_social,w_member_social,w_organization_social"
) |>
httr2::req_headers(
`Linkedin-Version` = "202403"
`Linkedin-Version` = li_version
)

li_perform <- function(post_req) {
Expand Down
21 changes: 16 additions & 5 deletions helpers-mastodon.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
tt_toot <- function(status_msg, img_paths, alt_text) {
rtoot::post_toot(
status = status_msg,
media = img_paths,
alt_text = alt_text
)
i <- 0L
status_code <- 0L
while (status_code != 200L && i < 5L) {
res <- rtoot::post_toot(
status = status_msg,
media = img_paths,
alt_text = alt_text
)
status_code <- res$status_code
i <- i + 1L
}
if (status_code != 200L) {
stop("Mastodon broke!")
}

return(res)
}
113 changes: 58 additions & 55 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"Version": "4.4.1",
"Repositories": [
{
"Name": "CRAN",
"URL": "https://cran.rstudio.com"
"Name": "P3M",
"URL": "https://packagemanager.posit.co/cran/latest"
},
{
"Name": "ropensci",
"URL": "https://ropensci.r-universe.dev"
}
]
},
Expand All @@ -23,7 +27,7 @@
"Package": "Rcpp",
"Version": "1.0.13",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "https://cran.rstudio.com",
"Requirements": [
"methods",
"utils"
Expand All @@ -32,37 +36,37 @@
},
"askpass": {
"Package": "askpass",
"Version": "1.2.0",
"Version": "1.2.1",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"sys"
],
"Hash": "cad6cf7f1d5f6e906700b9d3e718c796"
"Hash": "c39f4155b3ceb1a9a2799d700fbd4b6a"
},
"bit": {
"Package": "bit",
"Version": "4.0.5",
"Version": "4.5.0",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"R"
],
"Hash": "d242abec29412ce988848d0294b208fd"
"Hash": "5dc7b2677d65d0e874fc4aaf0e879987"
},
"bit64": {
"Package": "bit64",
"Version": "4.0.5",
"Version": "4.5.2",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"R",
"bit",
"methods",
"stats",
"utils"
],
"Hash": "9fe98599ca456d6552421db0d6772d8f"
"Hash": "e84984bf5f12a18628d9a02322128dfd"
},
"cli": {
"Package": "cli",
Expand All @@ -87,13 +91,13 @@
},
"cpp11": {
"Package": "cpp11",
"Version": "0.4.7",
"Version": "0.5.0",
"Source": "Repository",
"Repository": "RSPM",
"Repository": "P3M",
"Requirements": [
"R"
],
"Hash": "5a295d7d963cc5035284dcdbaf334f4e"
"Hash": "91570bba75d0c9d3f1040c835cee8fba"
},
"crayon": {
"Package": "crayon",
Expand All @@ -109,27 +113,27 @@
},
"credentials": {
"Package": "credentials",
"Version": "2.0.1",
"Version": "2.0.2",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"askpass",
"curl",
"jsonlite",
"openssl",
"sys"
],
"Hash": "c7844b32098dcbd1c59cbd8dddb4ecc6"
"Hash": "09fd631e607a236f8cc7f9604db32cb8"
},
"curl": {
"Package": "curl",
"Version": "5.2.1",
"Version": "5.2.3",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"R"
],
"Hash": "411ca2c03b1ce5f548345d2fc2685f7a"
"Hash": "d91263322a58af798f6cf3b13fd56dde"
},
"desc": {
"Package": "desc",
Expand Down Expand Up @@ -223,9 +227,9 @@
},
"gert": {
"Package": "gert",
"Version": "2.1.1",
"Version": "2.1.4",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"askpass",
"credentials",
Expand All @@ -234,7 +238,7 @@
"sys",
"zip"
],
"Hash": "ab2ca7d6bd706ed218d096b7b16d7233"
"Hash": "ae855ad6d7be20dd7b05d43d25700398"
},
"gh": {
"Package": "gh",
Expand Down Expand Up @@ -266,14 +270,14 @@
},
"glue": {
"Package": "glue",
"Version": "1.7.0",
"Version": "1.8.0",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"R",
"methods"
],
"Hash": "e0b3a53876554bd45879e596cdb10a52"
"Hash": "5899f1eaa825580172bb56c08266f37c"
},
"hms": {
"Package": "hms",
Expand Down Expand Up @@ -321,9 +325,9 @@
},
"httr2": {
"Package": "httr2",
"Version": "1.0.2",
"Version": "1.0.5",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"R",
"R6",
Expand All @@ -338,7 +342,7 @@
"vctrs",
"withr"
],
"Hash": "320c8fe23fcb25a6690ef7bdb6a3a705"
"Hash": "d84e4c33206aaace37714901ac2b00c3"
},
"ini": {
"Package": "ini",
Expand All @@ -349,13 +353,13 @@
},
"jsonlite": {
"Package": "jsonlite",
"Version": "1.8.8",
"Version": "1.8.9",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"methods"
],
"Hash": "e1b9c55281c5adc4dd113652d9e26768"
"Hash": "4e993b65c2c3ffbffce7bb3e2c6f832b"
},
"later": {
"Package": "later",
Expand Down Expand Up @@ -416,13 +420,13 @@
},
"openssl": {
"Package": "openssl",
"Version": "2.2.1",
"Version": "2.2.2",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"askpass"
],
"Hash": "c62edf62de70cadf40553e10c739049d"
"Hash": "d413e0fef796c9401a4419485f709ca1"
},
"pillar": {
"Package": "pillar",
Expand Down Expand Up @@ -541,13 +545,13 @@
},
"renv": {
"Package": "renv",
"Version": "1.0.7",
"Version": "1.0.11",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "P3M",
"Requirements": [
"utils"
],
"Hash": "397b7b2a265bc5a7a06852524dabae20"
"Hash": "47623f66b4e80b3b0587bc5d7b309888"
},
"rlang": {
"Package": "rlang",
Expand All @@ -572,10 +576,10 @@
},
"rstudioapi": {
"Package": "rstudioapi",
"Version": "0.16.0",
"Version": "0.17.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "96710351d642b70e8f02ddeb237c46a7"
"Repository": "P3M",
"Hash": "fb9f5fce8f609e9b66f0bea5c783f88a"
},
"rtoot": {
"Package": "rtoot",
Expand Down Expand Up @@ -673,10 +677,10 @@
},
"sys": {
"Package": "sys",
"Version": "3.4.2",
"Version": "3.4.3",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "3a1be13d68d47a8cd0bfd74739ca1555"
"Repository": "P3M",
"Hash": "de342ebfebdbf40477d0758d05426646"
},
"tibble": {
"Package": "tibble",
Expand All @@ -701,7 +705,7 @@
"Package": "tidyr",
"Version": "1.3.1",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "https://cran.rstudio.com",
"Requirements": [
"R",
"cli",
Expand Down Expand Up @@ -738,15 +742,14 @@
},
"tidytuesdayR": {
"Package": "tidytuesdayR",
"Version": "1.0.3.9000",
"Version": "1.1.2.9000",
"Source": "GitHub",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteRepo": "tidytuesdayR",
"RemoteUsername": "dslc-io",
"RemotePkgRef": "dslc-io/tidytuesdayR",
"RemoteRef": "HEAD",
"RemoteSha": "71313cd916c6ebda8ec3572683dc22f6ecbe33f2",
"RemoteRepo": "tidytuesdayR",
"RemoteRef": "main",
"RemoteSha": "a6ab3546466a99dfff5a11dbf2c5185942e5f58a",
"Requirements": [
"R",
"cli",
Expand All @@ -764,7 +767,7 @@
"usethis",
"xml2"
],
"Hash": "0356d320ccacac62b1ce8968d0b062b1"
"Hash": "fefd13658196ca2274d77ce19cfa4d50"
},
"timechange": {
"Package": "timechange",
Expand Down Expand Up @@ -792,7 +795,7 @@
"Package": "usethis",
"Version": "3.0.0",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "https://cran.rstudio.com",
"Requirements": [
"R",
"cli",
Expand Down Expand Up @@ -880,7 +883,7 @@
"Package": "withr",
"Version": "3.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "https://cran.rstudio.com",
"Requirements": [
"R",
"grDevices",
Expand All @@ -905,7 +908,7 @@
"Package": "yaml",
"Version": "2.3.10",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "https://cran.rstudio.com",
"Hash": "51dab85c6c98e50a18d7551e9d49f76c"
},
"zip": {
Expand Down
Loading

0 comments on commit fd2c5fe

Please sign in to comment.