summaryrefslogtreecommitdiff
path: root/helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.rb')
-rw-r--r--helpers.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/helpers.rb b/helpers.rb
index 41dcc33..75221f8 100644
--- a/helpers.rb
+++ b/helpers.rb
@@ -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']