From bfe675b0da2b95d234f4ffbc05017b01008cdae0 Mon Sep 17 00:00:00 2001 From: Kuba Suder Date: Sat, 30 Nov 2024 23:14:11 +0200 Subject: [PATCH] fixed error when alt is longer than 1500 --- app/mastodon_account.rb | 4 ++++ app/tootify.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/mastodon_account.rb b/app/mastodon_account.rb index 0852397..02b0420 100644 --- a/app/mastodon_account.rb +++ b/app/mastodon_account.rb @@ -12,6 +12,10 @@ class MastodonAccount @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 diff --git a/app/tootify.rb b/app/tootify.rb index bbfae87..3c3882a 100644 --- a/app/tootify.rb +++ b/app/tootify.rb @@ -106,6 +106,10 @@ class Tootify 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) -- 2.51.2