+24
-3
app/tootify.rb
+24
-3
app/tootify.rb
···
130
130
if @config['extract_link_from_quotes']
131
131
quoted_record = fetch_record_by_at_uri(quote_uri)
132
132
133
-
if link_from_quote = link_embed(quoted_record)
134
-
link_to_append = link_from_quote
133
+
quote_link = link_embed(quoted_record)
134
+
135
+
if quote_link.nil?
136
+
text_links = links_from_facets(quoted_record)
137
+
quote_link = text_links.first if text_links.length == 1
138
+
end
139
+
140
+
if quote_link
141
+
link_to_append = quote_link
135
142
end
136
143
end
137
144
···
206
213
bytes.pack('C*').force_encoding('UTF-8')
207
214
end
208
215
216
+
def links_from_facets(record)
217
+
links = []
218
+
219
+
if facets = record['facets']
220
+
facets.each do |f|
221
+
if link = f['features'].detect { |ft| ft['$type'] == 'app.bsky.richtext.facet#link' }
222
+
links << link['uri']
223
+
end
224
+
end
225
+
end
226
+
227
+
links.reject { |x| x.start_with?('https://bsky.app/hashtag/') }
228
+
end
229
+
209
230
def link_embed(record)
210
231
if embed = record['embed']
211
232
case embed['$type']
···
267
288
end
268
289
269
290
def append_link(text, link)
270
-
if link =~ /^https:\/\/bsky\.app\/profile\/.+\/post\/.+/
291
+
if link =~ %r{^https://bsky\.app/profile/.+/post/.+}
271
292
text << "\n" unless text.end_with?("\n")
272
293
text << "\n"
273
294
text << "RE: " + link