diff options
Diffstat (limited to 'helpers.rb')
-rw-r--r-- | helpers.rb | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,10 @@ require 'English' helpers do + def save_item(item, path) + FileUtils.mkdir_p File.dirname(path) + File.open(path, 'w+') { |f| f.puts item.to_json } + end + # add date and id, save def save_activity(activity, box) date = Time.now.utc.iso8601 @@ -24,9 +29,7 @@ helpers do def save_object(object, box) object = fetch(object) if object.is_a? String and object.match(/^http/) return unless object and object['type'] != 'Person' - # File.open(File.join(INBOX[:dir]), 'visited', 'w+').open { |f| f.puts object['id'] } - return if box == INBOX and object['id'] and File.readlines(File.join(INBOX[:dir], 'visited'), - chomp: true).include? object['id'] + return if box == INBOX and object['id'] and File.readlines(VISITED, chomp: true).include? object['id'] object['@context'] = 'https://www.w3.org/ns/activitystreams' if object['attributedTo'] |