Toot toooooooot (Bluesky-Mastodon cross-poster)

fixed error if image/video alt is not set

Changed files
+7 -4
app
+5 -2
app/mastodon_api.rb
··· 73 73 headers = { 'Authorization' => "Bearer #{@access_token}" } 74 74 75 75 form_data = [ 76 - ['file', data, { :filename => filename, :content_type => content_type }], 77 - ['description', alt.to_s.force_encoding('ASCII-8BIT')] 76 + ['file', data, { :filename => filename, :content_type => content_type }] 78 77 ] 78 + 79 + if alt 80 + form_data << ['description', alt.force_encoding('ASCII-8BIT')] 81 + end 79 82 80 83 request = Net::HTTP::Post.new(url, headers) 81 84 request.set_form(form_data, 'multipart/form-data')
+2 -2
app/tootify.rb
··· 154 154 cid = embed['image']['ref']['$link'] 155 155 mime = embed['image']['mimeType'] 156 156 157 - if alt.length > @mastodon.max_alt_length 157 + if alt && alt.length > @mastodon.max_alt_length 158 158 alt = alt[0...@mastodon.max_alt_length - 3] + "(…)" 159 159 end 160 160 ··· 168 168 cid = embed['video']['ref']['$link'] 169 169 mime = embed['video']['mimeType'] 170 170 171 - if alt.length > @mastodon.max_alt_length 171 + if alt && alt.length > @mastodon.max_alt_length 172 172 alt = alt[0...@mastodon.max_alt_length - 3] + "(…)" 173 173 end 174 174