diff options
-rw-r--r-- | application.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/application.rb b/application.rb index 66b47b2..fe84d61 100644 --- a/application.rb +++ b/application.rb @@ -2,9 +2,7 @@ # run as service # federation # client post media -# client follow # client get media -# server follow # test with pleroma etc require 'json' require 'net/http' @@ -171,7 +169,8 @@ class Application "type" => "Note", "attributedTo" => ACTOR, "published" => date, - "content" => "" + "content" => "", + "to" => ["https://www.w3.org/ns/activitystreams#Public"] } create = { "@context" => "https://www.w3.org/ns/activitystreams", @@ -180,6 +179,7 @@ class Application "actor" => ACTOR, "object" => note, "published" => date, + "to" => ["https://www.w3.org/ns/activitystreams#Public"] } recipients = [] if /^@/.match input @@ -192,8 +192,8 @@ class Application recipients += Dir[File.join("followers", "*.json")].collect { |f| JSON.parse(File.read(f))["actor"] } recipients.delete ACTOR recipients.uniq! - note["to"] = recipients - create["to"] = recipients + note["to"] += recipients + create["to"] += recipients save create save note @@ -215,7 +215,7 @@ class Application response = response["orderedItems"].collect.with_index do |r, i| object = r["object"] doc = Nokogiri::HTML(object["content"]) - str = "#{i}\t#{object["published"]}\t#{}\n#{doc.text}" + str = "#{i}\t#{object["published"]}\t#{mention r["actor"]}\n\n#{doc.text}" str << "\n" + object["attachment"].collect { |att| `kitty +kitten icat #{att["url"]}` }.join("\n") if object["attachment"] @@ -238,6 +238,10 @@ class Application }[0]["href"] end + def mention actor + "#{get(actor)["preferredUsername"]}@#{URI(actor).host}" + end + def send object, urls # puts object, urls # https://github.com/mastodon/mastodon/blob/main/app/lib/request.rb |