From 3a87028b34c969744f6c63ba73947cfa32156e7d Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sat, 9 Sep 2023 16:02:50 +0200 Subject: update and clean-inbox added, no outbox send for delete, recursive create for objects with activities (lemmy) --- helpers.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'helpers.rb') 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'] -- cgit v1.2.3