gesistsa / rtoot

:mammoth: R package to interact with the mastodon API
https://gesistsa.github.io/rtoot/
Other
104 stars 14 forks source link

Feature request: `boost_toot()` function #134

Closed rempsyc closed 1 year ago

rempsyc commented 1 year ago

Hi, it would be nice if we could boost toots with the rtoot package, say with a boost_toot() function.

> library("rtoot")
> boost_toot()
Error in boost_toot() : could not find function "boost_toot"

Is there already a way to do this through an existing function?

rempsyc commented 1 year ago

From: https://docs.joinmastodon.org/methods/statuses/#boost

Boost a status
POST /api/v1/statuses/:id/reblog HTTP/1.1
Reshare a status on your own profile.

What I've tried:

library(rtoot)
post_id <- 110618427914578591
boost_endpoint <- paste0("api/v1/statuses/", post_id, "/reblog")
boost_endpoint
#> [1] "api/v1/statuses/110618427914578592/reblog"
boost_response <- rtoot(boost_endpoint, method = "POST")
#> Error: something went wrong. Status code: 404
boost_response <- rtoot(boost_endpoint, method = "HTTP/1.1")
#> Error: something went wrong. Status code: 404
404: Not found
Status does not exist or is private

{
  "error": "Record not found"
}
rempsyc commented 1 year ago

But trying the get_status() example I am getting the same error:

get_status(id = "109298295023649405")
#> Error: something went wrong. Status code: 404

get_reblogged_by(id = "109294719267373593")
#> Error: something went wrong. Status code: 404

get_favourited_by(id = "109294719267373593")
#> Error: something went wrong. Status code: 404
schochastics commented 1 year ago

The example in get_status() seemed broken. I fixed that. I also added post_status which works similar to post_user to favourite/reblog/bookmark statuses. So you can boost now :)

rempsyc commented 1 year ago

Wow, awesome, that was quick! 😮😃

schochastics commented 1 year ago

You got me exactly on my monthly dev day 😉

rempsyc commented 1 year ago

Some more work for you, for next monthly dev day perhaps :P

library(rtoot)

# Works on same instance
post_id <- 110635249481533536
post_status(post_id)
#> successfully performed action on status

# Fails with no message on other instance
post_id <- 110618427914578591
post_status(post_id)

# Unused argument 'instance' like for `get_status()`
post_status(post_id, instance = "mastodon.world")
#> Error in post_status(post_id, instance = "mastodon.world"): unused argument (instance = "mastodon.world")

Created on 2023-06-30 with reprex v2.0.2

chainsawriot commented 1 year ago

Welcome to the Fediverse

https://github.com/mastodon/mastodon/issues/7888