lib/ayadn/workers.rb in ayadn-1.7.6 vs lib/ayadn/workers.rb in ayadn-1.7.7
- old
+ new
@@ -260,14 +260,35 @@
def extract_links(post)
links = post['entities']['links'].map { |l| l['url'] }
unless post['annotations'].nil? || post['annotations'].empty?
post['annotations'].each do |ann|
if ann['type'] == "net.app.core.oembed"
- links << ann['value']['embeddable_url'] if ann['value']['embeddable_url']
+ if ann['value']['embeddable_url']
+ links << ann['value']['embeddable_url']
+ elsif ann['value']['url'] && Settings.options[:timeline][:show_channel_oembed] == true
+ links << ann['value']['url']
+ end
end
end
end
links.uniq
+ end
+
+ def save_links(links, origin, args = "")
+ links.sort!
+ obj = {
+ 'meta' => {
+ 'type' => 'links',
+ 'origin' => origin,
+ 'args' => args,
+ 'created_at' => Time.now,
+ 'username' => Settings.config[:identity][:handle]
+ },
+ 'data' => links
+ }
+ filename = "#{Settings.config[:identity][:handle]}_#{origin}_links.json"
+ FileOps.save_links(obj, filename)
+ puts Status.links_saved(filename)
end
def extract_hashtags(post)
post['entities']['hashtags'].map { |h| h['name'] }
end