Skip to content

Commit

Permalink
closes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Oct 1, 2024
1 parent 3cb845a commit 47f2420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Description: Wraps the 'AT' Protocol (Authenticated Transfer Protocol) behind
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Imports:
cli,
glue,
Expand Down
10 changes: 7 additions & 3 deletions R/utils.r
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,13 @@ str_locate_all_bytes <- function(string, pattern) {


fetch_preview <- function(record) {
uri <- purrr::pluck(record, "facets", 1, "features", 1, "uri",
.default = NA_character_)
if (!is.na(uri)) {
facets <- purrr::pluck(record, "facets")
uri <- purrr::map_chr(facets, function(f)
purrr::pluck(f, "features", 1, "uri", .default = NA_character_)) |>
stats::na.omit() |>
utils::head(1L) # only one link can be previewed

if (length(uri) > 0L) {
# this is the API bsky.app is using. Not sure how robust it is
preview <- httr2::request("https://cardyb.bsky.app/v1/extract") |>
httr2::req_url_query(url = uri) |>
Expand Down

0 comments on commit 47f2420

Please sign in to comment.