Open ushitora-anqou opened 4 years ago
I second this - doing a bundle update
in my project, specifying spec.add_runtime_dependency 'mastodon-api', '~> 2.0'
, seems to bring down dependencies with versions like:
...
Using http 3.3.0
...
... whereas master
has version 4, so I'd expect it to be using a version on 4.X
, rather than 3.3.0. As mastodon-api
is the only thing in my application making HTTP calls, I'm fairly certain that a new release is required.
I get an exception with Ruby 2.7, calling create_status
:
FrozenError: can't modify frozen String: ""
/home/shavs/.gem/gems/http-3.3.0/lib/http/response/body.rb:52:in `force_encoding'
/home/shavs/.gem/gems/http-3.3.0/lib/http/response/body.rb:52:in `to_s'
/usr/lib/ruby/2.7.0/forwardable.rb:229:in `empty?'
/home/shavs/.gem/gems/mastodon-api-2.0.0/lib/mastodon/rest/request.rb:26:in `perform'
/home/shavs/.gem/gems/mastodon-api-2.0.0/lib/mastodon/rest/utils.rb:10:in `perform_request'
/home/shavs/.gem/gems/mastodon-api-2.0.0/lib/mastodon/rest/utils.rb:18:in `perform_request_with_object'
/home/shavs/.gem/gems/mastodon-api-2.0.0/lib/mastodon/rest/statuses.rb:24:in `create_status'
(oddly, I still receive the status, even though there is an exception... :shrug: )
I'm relatively new to Ruby (but I'm familiar with JS/PHP dev workflows), so feel free to correct me if I'm wrong with any of this info!
I really gotta sit down and go over this gem again and make sure all the APIs that Mastodon has are properly represented in it then push a new release out :grimacing:
Hopefully this is of some use, and I apologise if this is a wall of text/Markdown, but here is a list of all the API endpoints not currently implemented:
GET
/api/v1/accounts/#{id}/statuses
GET
/api/v1/accounts/#{id}/lists
GET
/api/v1/accounts/#{id}/identity_proofs
POST
/api/v1/accounts/#{id}/pin
POST
/api/v1/accounts/#{id}/unpin
GET
/api/v1/bookmarks
GET
/api/v1/favourites
/api/v1/reports
)GET
/api/v1/reports
POST
/api/v1/reports
/api/v1/featured_tags
)GET
/api/v1/featured_tags
POST
/api/v1/featured_tags
DELETE
/api/v1/featured_tags/#{id}
GET
/api/v1/featured_tags/suggestions
/api/v1/preferences
)GET
/api/v1/preferences
GET
/api/v1/suggestions
DELETE
/api/v1/suggestions/#{account_id}
GET
/api/v1/oauth/authorize
POST
/api/v1//oauth/token
POST
/api/v1/oauth/revoke
GET
/api/v1/media/#{id}
GET
/api/v1/polls/#{id}
POST
/api/v1/polls/#{id}/votes
GET
/api/v1/markers
POST
/api/v1/markers
GET
/api/v1/notifications/#{id}
POST
/api/v1/notifications/#{id}/dismiss
POST
/api/v1/push/subscription
GET
/api/v1/push/subscription
PUT
/api/v1/push/subscription
DELETE
/api/v1/push/subscription
GET
/api/v1/trends
GET
/api/v1/directory
GET
/api/v1/announcements
POST
/api/v1/announcements/#{id}/dismiss
PUT
/api/v1/announcements/#{id}/reactions/#{name}
DELETE
/api/v1/announcements/#{id}/reactions/#{name}
GET
/api/proofs
GET
/api/oembed
timelines/streaming
might need manual review, I didn't look deeply into these endpoints as they're related to streaming APIs.I went through the documentation currently available on JoinMastodon, so hopefully this covers it all. However, it was all done by hand, so there may be some issues with it. And, feel free to copy it etc. so that you can format it however you please! :+1:
I can confirm that mastodon-api
is throwing this error when used in Ruby 2.7.
I am using mastodon-api
in a project that also uses the twitter
gem, and I have to use an older version of the twitter
gem because of the conflict between http 3.3.0
and http 4.4.1
.
Same issue here
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
Traceback (most recent call last):
7: from /home/gregory/bin/ecchi:179:in `<main>'
6: from /home/gregory/.gem/ruby/2.7.0/gems/mastodon-api-2.0.0/lib/mastodon/rest/media.rb:17:in `upload_media'
5: from /home/gregory/.gem/ruby/2.7.0/gems/mastodon-api-2.0.0/lib/mastodon/rest/utils.rb:18:in `perform_request_with_object'
4: from /home/gregory/.gem/ruby/2.7.0/gems/mastodon-api-2.0.0/lib/mastodon/rest/utils.rb:10:in `perform_request'
3: from /home/gregory/.gem/ruby/2.7.0/gems/mastodon-api-2.0.0/lib/mastodon/rest/request.rb:26:in `perform'
2: from /usr/lib/ruby/2.7.0/forwardable.rb:229:in `empty?'
1: from /home/gregory/.gem/ruby/2.7.0/gems/http-3.3.0/lib/http/response/body.rb:52:in `to_s'
/home/gregory/.gem/ruby/2.7.0/gems/http-3.3.0/lib/http/response/body.rb:52:in `force_encoding': can't modify frozen String: "" (FrozenError)
Bumping. This seems to have been broken for some time. Similar errors under Ruby 3.x.
[5] pry(main)> client.conversations
FrozenError: can't modify frozen String: ""
from /usr/local/lib/ruby/gems/3.1/gems/http-3.3.0/lib/http/response/body.rb:52:in `force_encoding'
I stopped using this gem some time ago. It's possible to post to Mastodon with the HTTP gem and a Mastodon bearer token. I remember seeing a tutorial on doing this in Python, and somehow I figured it out in Ruby. I can't find where I did that, and now that Mastodon has all of this newfound popularity maybe I should write up how I did it.
If I or someone else can find a tutorial on how to do this, hopefully you (or I) can post it.
This PR resolves the FrozenError, but hasn't been shipped yet. You can fork from that repo source and install from the branch for now, if nothing else.
@passthejoe Your comment here was really helpful. I only need to write statuses, and it was proving to be a big hassle to get this gem working given all the ancient dependencies. I looked at your repo and saw how you're using the http gem: https://github.com/passthejoe/blogPoster/blob/d2cfa6815f995b4e81ee548f51e35b0225994eb8/blogPoster.rb#L631
HTTP.auth("Bearer " + @mastodon_bearer_token)
.post(@mastodon_base_url + "/api/v1/statuses", :params => {:status => @yourText + " " + @yourURL})
Works great - very simple!
It was a nice discovery. I think I saw somebody do it in Python and then just hacked it into Ruby.
On Sun, Mar 19, 2023 at 6:37 PM Ryan TG @.***> wrote:
@passthejoe https://github.com/passthejoe Your comment here was really helpful. I only need to write statuses, and it was proving to be a big hassle to get this gem working given all the ancient dependencies. I looked at your repo and saw how you're using the http gem: https://github.com/passthejoe/blogPoster/blob/d2cfa6815f995b4e81ee548f51e35b0225994eb8/blogPoster.rb#L631
HTTP.auth("Bearer " + @mastodon_bearer_token) .@.***_base_url + "/api/v1/statuses", :params => {:status => @yourText + " " + @yourURL})
Works great - very simple!
— Reply to this email directly, view it on GitHub https://github.com/mastodon/mastodon-api/issues/49#issuecomment-1475487067, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAX2TB445PGEIEBZCIIW6X3W46YFRANCNFSM4OQNRL5A . You are receiving this because you were mentioned.Message ID: @.***>
The following code doesn't run on the latest release (2.0.0) with Ruby 2.7.1, but works fine on the master branch.
Maybe a new release is required?