Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release for Ruby 2.7.1 #49

Open
ushitora-anqou opened this issue Jul 4, 2020 · 10 comments
Open

New release for Ruby 2.7.1 #49

ushitora-anqou opened this issue Jul 4, 2020 · 10 comments

Comments

@ushitora-anqou
Copy link

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.

rest = Mastodon::REST::Client.new(base_url: "...", bearer_token: "...")
rest.verify_credentials

Maybe a new release is required?

@shavs
Copy link

shavs commented Jul 4, 2020

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... 🤷 )

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!

@Gargron
Copy link
Member

Gargron commented Jul 5, 2020

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 😬

@shavs
Copy link

shavs commented Jul 8, 2020

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:

Missing endpoints:

  • Accounts
    • Main account methods
      • Statuses
        • Method: GET
        • Route: /api/v1/accounts/#{id}/statuses
      • Lists
        • Method: GET
        • Route: /api/v1/accounts/#{id}/lists
      • Identity Proofs
        • Method: GET
        • Route: /api/v1/accounts/#{id}/identity_proofs
      • Feature on Profile (pins)
        • Method: POST
        • Route: /api/v1/accounts/#{id}/pin
      • Unfeature on Profile (unpin)
        • Method: POST
        • Route: /api/v1/accounts/#{id}/unpin
    • Bookmarks (might be deprecated, though - also, see Statuses)
      • Method: GET
      • Route: /api/v1/bookmarks
    • Favorites
      • Method: GET
      • Route: /api/v1/favourites
    • Reports (some of the documentation is also missing in the API docs) (/api/v1/reports)
      • File a report
        • Method: GET
        • Route: /api/v1/reports
      • Create a Report
        • Method: POST
        • Route: /api/v1/reports
    • Featured Tags (/api/v1/featured_tags)
      • View your featured tags
        • Method: GET
        • Route: /api/v1/featured_tags
      • Feature a tag
        • Method: POST
        • Route: /api/v1/featured_tags
      • Unfeature a tag
        • Method: DELETE
        • Route: /api/v1/featured_tags/#{id}
      • Suggested tags to feature
        • Method: GET
        • Route: /api/v1/featured_tags/suggestions
    • Preferences (/api/v1/preferences)
      • View user preferences
        • Method: GET
        • Route: /api/v1/preferences
    • Suggestions
      • Follow suggestions
        • Method: GET
        • Route: /api/v1/suggestions
      • Remove a suggestion
        • Method: DELETE
        • Route: /api/v1/suggestions/#{account_id}
  • Apps
    • OAuth
      • Authorize
        • Method: GET
        • Route: /api/v1/oauth/authorize
      • Obtain a Token
        • Method: POST
        • Route: /api/v1//oauth/token
      • Revoke token
        • Method: POST
        • Route: /api/v1/oauth/revoke
  • Statuses
    • Media
      • Update an attachment (Get an Attachment, before it is attached to a status and posted...)
        • Method: GET
        • Route: /api/v1/media/#{id}
      • Focal points
        • No direct API documentation exists for this
    • Polls (I'm not sure whether all API endpoints are documented)
      • View a poll
        • Method: GET
        • Route: /api/v1/polls/#{id}
      • Vote on a poll
        • Method: POST
        • Route: /api/v1/polls/#{id}/votes
  • Timelines
    • Markers
      • Get saved timeline position
        • Method: GET
        • Route: /api/v1/markers
      • Save position in timeline
        • Method: POST
        • Route: /api/v1/markers
  • Notifications
    • Main notification methods
      • Get a single notification
        • Method: GET
        • Route: /api/v1/notifications/#{id}
      • Dismiss a single notification
        • Method: POST
        • Route: /api/v1/notifications/#{id}/dismiss
    • Push
      • Subscribe to push notifications
        • Method: POST
        • Route: /api/v1/push/subscription
      • Get current subscription
        • Method: GET
        • Route: /api/v1/push/subscription
      • Change types of notifications
        • Method: PUT
        • Route: /api/v1/push/subscription
      • Remove current subscription
        • Method: DELETE
        • Route: /api/v1/push/subscription
  • Trends
    • Trending tags
      • Method: GET
      • Route: /api/v1/trends
  • Directory
    • View profile directory
      • Method: GET
      • Route /api/v1/directory
  • Admin (not currently complete documentation for API)
  • Announcements
    • View all announcements
      • Method: GET
      • Route: /api/v1/announcements
    • Dismiss an announcements
      • Method: POST
      • Route: /api/v1/announcements/#{id}/dismiss
    • Add reaction
      • Method: PUT
      • Route: /api/v1/announcements/#{id}/reactions/#{name}
    • Remove reaction
      • Method: DELETE
      • Route: /api/v1/announcements/#{id}/reactions/#{name}
  • Proofs
    • View identity proof
      • Method: GET
      • Route: /api/proofs
  • OEmbed
    • OEmbed as JSON
      • Method: GET
      • Route: /api/oembed

Other notes

  • 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! 👍

@passthejoe
Copy link

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.

tekniklr added a commit to tekniklr/tekniklr.com that referenced this issue Nov 14, 2020
@reinboldg
Copy link

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)

tekniklr added a commit to tekniklr/tekniklr.com that referenced this issue Mar 19, 2021
@mahlonsmith
Copy link

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'

@passthejoe
Copy link

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.

@hortoncd
Copy link

hortoncd commented Feb 4, 2023

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.

@RyanTG
Copy link

RyanTG commented Mar 20, 2023

@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!

@passthejoe
Copy link

passthejoe commented Apr 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants