Skip to content

Commit

Permalink
fixed error when alt is longer than 1500
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed Nov 30, 2024
1 parent c808867 commit bfe675b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/mastodon_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def initialize
@config = File.exist?(CONFIG_FILE) ? YAML.load(File.read(CONFIG_FILE)) : {}
end

def max_alt_length
1500
end

def save_config
File.write(CONFIG_FILE, YAML.dump(@config))
end
Expand Down
4 changes: 4 additions & 0 deletions app/tootify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def post_to_mastodon(record)
cid = image['image']['ref']['$link']
mime = image['image']['mimeType']

if alt.length > @mastodon.max_alt_length
alt = alt[0...@mastodon.max_alt_length - 3] + "(…)"
end

data = @bluesky.fetch_blob(cid)

uploaded_media = @mastodon.upload_media(data, cid, mime, alt)
Expand Down

0 comments on commit bfe675b

Please sign in to comment.