summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-05-20 22:52:27 +0200
committerpdp8 <pdp8@pdp8.info>2023-05-20 22:52:27 +0200
commitb5adfb4a21b38902e5ce505911d520a467d6f42a (patch)
tree91360cced9bf94f5faf910eba235b425f4f55e13 /application.rb
parenta20dbc5497ffc460cf14a175da985315080853dd (diff)
public posts, inbox rendering
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb16
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